There is a lot of speculation about adding a WordPress Search Form. On the other hand, WordPress provides a lot of filters (and actions) to allow plugins or themes to modify WordPress comportment. Among them, ‘get_search_form’ can be used to modify the search form.
If a theme author codes a search form that does not pass through this filter, no plugin is aware of this search form and thus no plugin can modify it for its own purposes.
Interestingly most people want to know if they can WordPress search forms using PHP code in your post or page content using a shortcode.
Well, the answer to that question is Yes. In this article, we will show you how to add the search form in your post or page content by creating a WordPress search shortcode.
WordPress Search Form Using PHP Code
All you have to do is open your theme’s functions.php file or a site-specific plugin and paste the following code:
Make sure to understand that this code is primarily used to hard code the search form. It is mainly done to change the search form to a sidebar along with a search widget for WordPress.
Then use the shortcode in your post/page content like so: [wpbsearch]
This will display the default search form. If you want to display a custom search form, then you can do so like this:
- Install WP fastest site search plugin from WordPress plugin store.
- Go to https://cse.expertrec.com/newuser?platform=wordpress.
- Enter your WordPress website URL and click on next->
- The crawl will start in the background.
- Login to your WordPress admin panel.
- In your left panel you must be able to see expertrec’s WordPress plugin, click on that.
- Get your site ID (or) API key from your expertrec control panel ( here ).
- Copy paste your site id in your WordPress control panel and click on save changes.
- Make sure you have upgraded to a paid plan before 15 days of free trial. (Price begins at 9 USD per month)
- That’s it! Your brand new WordPress search is up and running!
Watch this video to learn more about WordPress Search Form