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.

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');

}
Wordpress no search.php

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

  1. Install WP fastest site search plugin from WordPress plugin store.
  2. Go to https://cse.expertrec.com/newuser?platform=wordpress.
  3. Enter your WordPress website URL and click on next->
  4. The crawl will start in the background.
  5. Login to your WordPress admin panel.
  6. In your left panel you must be able to see expertrec’s WordPress plugin, click on that.
  7. Get your site ID (or) API key from your expertrec control panel ( here ).
  8. Copy paste your site id in your WordPress control panel and click on save changes.
  9. Make sure you have upgraded to a paid plan before 15 days of free trial. (Price begins at 9 USD per month)
  10. 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 

 

You may also like