Why don't the search results in my Swiftype dashboard match what is displayed on my WordPress site?

wordpress

#1

I installed the Swiftype WordPress plugin and it indexed all my posts, but it doesn’t seem to be working on my site.

When I submit a search in the Swiftype dashboard, why do I get different results than when I submit a search directly on my site?

The Swiftype WordPress plugin works by overriding the standard WordPress search function, so it works fine with most themes as long as they don’t try to use the original version of the search function directly.

If you are receiving different results when you search in the Swiftype dashboard compared to when you search on your site, this usually means that the theme is calling the query_posts search function directly within your theme’s search.php file.

You can verify this by temporarily switching over to the Twenty Twelve WordPress theme. If Swiftype works with this theme, the issue is likely a conflict with your previous theme.

It may be worth contacting your theme developer because themes aren’t really supposed to work this way. According to the WordPress documentation regarding query_posts:

query_posts() is the easiest, but not preferred or most efficient, way to alter the default query that WordPress uses to display posts. Use query_posts() to display different posts than those that would normally show up at a specific URL. (The preferred way is hooking into pre_get_posts and altering the main query that way using is_main_query)

You can usually fix this yourself by looking at your theme’s search.php file. See if you can find a call that looks something like this:

query_posts($query_string .'&posts_per_page=10&paged=' . $paged);

Note that it probably will have different arguments, but if this is the problem, you will find a call to the query_posts function.

Once you find it, comment out that line and save the file:

// query_posts($query_string .'&posts_per_page=10&paged=' . $paged);

Swiftype-powered search results should now display correctly.

Note:

It has also been discovered that third party WordPress plug-ins can potentially be the source of conflicting search behavior. One such plug-in that has been confirmed to conflict with the Swiftype search plug-in is Theme My Login. Deactivating the conflicting plug-in(s) should restore your site’s Swiftype search functionality.