0

Currently I have 1 custom post type called 'guides' and a couple of custom fields. Now I want to display a search form on archive-guides.php where you people can search on the custom field champion.

This is my code in archive-guides:

<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>

This is my code in 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'); } };
?>

But It still wouldnt redirect to search-guides.php, if I search with the form the url will become /?s=query&post_type=guides (query = search term).

Any help appreciated!

4

2 回答 2

1

我认为https://wordpress.stackexchange.com/questions/89886/how-to-create-a-custom-search-for-custom-post-type帖子将帮助您为自定义帖子类型创建自定义搜索。

也很有帮助: http: //www.wpbeginner.com/wp-tutorials/how-to-create-advanced-search-form-in-wordpress-for-custom-post-types/

于 2013-10-20T19:51:40.580 回答
0

请更新您的 load_template 代码。

于 2013-10-20T19:04:30.610 回答