目前我有1個自定義帖子類型稱爲'指南'和一些自定義字段。現在我想在archive-guides.php上顯示一個搜索表單,人們可以在自定義字段冠軍上進行搜索。自定義帖子類型搜索模板
這是我在檔案導遊代碼:
<form id="searchform" action="<?php bloginfo('home'); ?>/" method="get">
<input id="s" maxlength="150" name="s" size="20" type="text" value="" class="txt" />
<input name="post_type" type="hidden" value="guides" />
<input id="searchsubmit" class="btn" type="submit" value="Search" />
</form>
這是我的search.php代碼:
<?php
$search_refer = $_GET["post_type"];
if ($search_refer == 'guides') {
if ('meta_key=champion&meta_value=$search_query') { load_template(TEMPLATEPATH . '/search-guides.php'); } };
?>
,但它仍然難道不重定向到搜索guides.php,如果我用表單搜索url將變成/?s=query&post_type=guides
(query = search term)。
任何幫助表示讚賞!
謝謝!經過仔細觀察教程後得到它的工作:) – Terry
非常歡迎你:) –