I have a custom post type recipes
which displays a paged list of recipes on the site using the archive-recipes.php
template.
I need to be able to search through these recipes using the search form at the top of the page:
<form role="search" method="get" class="searchbox" action="/recipes/">
<input type="text" class="textbox strong" name="s" id="s" value="" placeholder="Search..." />
<input type="hidden" name="post_type" value="recipes" />
<button type="submit" class="button icon"></button>
</form>
Is it possible to return to this recipe listing page once the search has been performed and display the results in the same style as the listings?
I can’t seem to find anything that will enable me to create a custom search page for custom post types.
Thanks for your help.
You could use the ‘template_include’ filter.
e.g. in your functions file.
This should check for a search on the ‘recipes’ custom post type and use your archive page template for the results.