Troubleshooting: Search results are missing or the same
SearchWP does its best to natively tie into WordPress. It does that by implementing a series of core WordPress hooks that swap out $wp_query->posts
at runtime when searches take place. In essence, that’s how SearchWP does its job. Unfortunately that doesn’t mean the implementation works with every theme and plugin out there. While it’s a solid approach with many themes and plugins, there are still some times where theme or plugin code prevents SearchWP from outputting relevant search results.
If after activating SearchWP and allowing it to build the initial index you are not seeing improved results (or no results are showing) please check the following:
Case 1: Missing search.php
in the theme folder
Many themes utilize what’s called a theme framework to handle a lot of their code. In many cases a part of the theme framework means relying less on WordPress’ Template Hierarchy and more on conditionals (e.g. is_search()
) inside the theme code and handling searches internally. In this process the theme framework sometimes performs its own search instead, omitting SearchWP’s results.
In this case it is usually best to create a child theme (see link for a description of what a child theme is) that does have its own search.php
. You will need to write the search results template from the ground up, but you can utilize the template files in the parent theme to build your search results template so it looks consistent. The theme author should be able to help you find which file(s) to work from.
Case 2: Redundant search in search.php
If your theme does in fact have a search.php
it may be performing its own redundant search. If you open search.php
and see any of the following, your theme is performing its own search instead of using the WordPress-provided results:
query_posts
new WP_Query
get_posts
If you search for and find any of the above in search.php
or any of the functions called in search.php
, it’s likely that your search template is re-running the search and using those results (omitting the results returned by SearchWP).
To resolve this issue you will need to remove the call, instead using a native implementation of The Loop in your search.php
.
Case 3: Plugin interference
SearchWP uses hooks to do its job, but so do many other plugins. Sometimes plugins (even though they have completely separate purposes) can step on each other’s toes and prevent some functionality. This is sometimes the case with certain types of plugins. The most common to date are plugins that allow you to add custom sorting to your posts. Please see the list of known plugin conflicts for a potential fix if you are not seeing accurate search results after activating SearchWP.