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!
I think https://wordpress.stackexchange.com/questions/89886/how-to-create-a-custom-search-for-custom-post-type post will help you to create custom search for custom post type.
Also helpful: http://www.wpbeginner.com/wp-tutorials/how-to-create-advanced-search-form-in-wordpress-for-custom-post-types/
Please update with your code for load_template.