我創建了一個wrodpress網站。我想有一個頁面,我可以發佈食譜。該頁面一次只能顯示5個食譜,但讓用戶在所有收件人之間導航。 事情是這樣的:添加帖子並進行搜索
Recipe 1
Recipe 2
Recipe 3
Recipe 4
Recipe 5
<Prev 2 3 4 5 .. Next>
我也希望遊客能夠搜索食譜。不像搜索整個頁面的正常搜索,但只搜索食譜帖子。
任何可以實現這一目標的插件建議?
我創建了一個wrodpress網站。我想有一個頁面,我可以發佈食譜。該頁面一次只能顯示5個食譜,但讓用戶在所有收件人之間導航。 事情是這樣的:添加帖子並進行搜索
Recipe 1
Recipe 2
Recipe 3
Recipe 4
Recipe 5
<Prev 2 3 4 5 .. Next>
我也希望遊客能夠搜索食譜。不像搜索整個頁面的正常搜索,但只搜索食譜帖子。
任何可以實現這一目標的插件建議?
這樣做的好方法是使用自定義帖子類型。本教程幾乎準確解釋了您想要做的事情,包括基於食譜的事實:http://wpmu.org/easy-guide-to-displaying-custom-post-types-in-your-wordpress-theme/
只要搜索僅限於該自定義帖子類型,您可以修改或複製searchform.php,而無需不必在所有使用插件:
<form role="search" method="get" id="searchform" action="<?php echo home_url('/'); ?>" >
<input type="text" name="s" id="s" value="Enter keywords ..."/>
<input type="hidden" name="post_type" value="recipes" />
<input type="submit" id="searchsubmit" value="Search Recipes" />
</form>
如果你有麻煩這項工作,確保被包含在search.php中的頂部以下內容:
<?php
global $query_string;
$query_args = explode("&", $query_string);
$search_query = array();
foreach($query_args as $key => $string) {
$query_split = explode("=", $string);
$search_query[$query_split[0]] = $query_split[1];
} // foreach
$search = new WP_Query($search_query);
?>
這看起來像我所需要的。非常感謝你! – iixi
使用谷歌。有幾個配方插件可供選擇。 – AndyWarren