How do you create a custom search form that should appear only on a particular page?
Using this
<?php get_search_form(); ?>
inserts wordpress's default search form to the page.Adding this
searchform.php
to my theme folder overwrites search functionality of the whole site
I want to add a search form which display posts from only a specific type of custom post type
and
the form should appear only in a specific page.(So the search forms in other pages should not be affected by this)
How to achieve this please. Any help is much appreciated.
Do not modify searchform.php, as you want to use the default search for other pages. The below html code will create a custom form for you. Just paste the code in the template and you got your custom search form.
Assuming that your custom post type is 'books'. By default your search results will use search.php file. So, we will check if the value is books then we will load a custom search query written in books-search.php. Otherwise you can load the existing code present is search.php.
In your search.php file:
Now in books-search.php use:
This will search only for books post type.