The search feature of WordPress displays published posts and pages. Mostly, when users look for elements in blogs, it is generally displayed as a post and not a page. There is configuration that needs to be done on WordPress Search.php to make these changes in case you want results to be displayed.
WordPress Search.php
Here, we will give you a brief glimpse of making search highly relevant and less crowded.
On the First go, add the given codes to the WordPress themes PHP file or a site-specific plugin to find WordPress Search.php.
//Exclude pages from WordPress Search if (!is_admin()) { function wpb_search_filter($query) { if ($query->is_search) { $query->set('post_type', 'post'); } return $query; } add_filter('pre_get_posts','wpb_search_filter'); }
The explanation here is that the code investigates that search is not originating from admin pages in WordPress. This is by setting the post type parameter.
Moreover, if you want to have an opposite set of real actual content of websites and making up words. For example, typing About us will show no results found. On the other hand, if you type “fsdgwdhs”, it will redirect you to some other page.
In order to avoid issues and make configuring easy when Search.php yields no results use WP fastest site search plugin by Expertrec
- 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!
Add great search to your wordpress site at 9 USD per month
For more information on WordPress Search.php results, you can visit