Yoast Local SEO plugin breaks Relevanssi search. It enhances the search by adding meta queries. Unfortunately they don’t work with Relevanssi. The fix is simple, though. Add this to the theme functions.php:
add_filter( 'relevanssi_modify_wp_query', 'rlv_meta_fix', 99 ); function rlv_meta_fix( $q ) { $q->set( 'meta_query', array() ); return $q; } |
This clears out the meta_query
. If you want to use other meta queries, this will make them fail as well.
This only applies to Yoast Local SEO. This does not apply to regular Yoast SEO.
where i have to add this code?
Theme functions.php, for example.
Put this in my functions.php and it still doesn’t work – the results are still blank! Whenever I disable Yoast Local, everything works fine, when I enable it, blank search. Any suggestions? Using Genesis WP Theme
If you add
global $wp_query; var_dump($wp_query->query_vars);
on your search results template, what does it print out?
Hi, I did that code, you mentioned below and it prints:
array(0) {}
I have themeforest’s Belief Theme, and I can see their template builder has layout settings for the search page (adjusted to “default” template here)
I disabled ACF and Yoast SEO, still the results come out blank like in this attachment.
I can see the index is working fine on the settings page, but no results after searching on the front end
What should I try?
I took the print while trying something to make Relevanssi work, don’t mind the “blog page” header, it reads “Search Results” normally here but no results. if I disable Relevanssi, search results appear normally
Try disabling your theme. It may be your theme is incompatible with Relevanssi.
Hello Mikko, firstly: I’m very happy with your plugin!
I have added this piece of code because I’m using Yoast. What I can’t understand: this works perfectly on 1 website (www.timhupkes.com/shop) but not at all on the basic website (www.timhupkes.com). It doesn’t find 1 word..! I have no idea what I could possibly do to improve matters… I’m using the theme Twenty Sixteen.
Are these two separate sites, parts of a multisite or what? Is Relevanssi installed on both sites, and do both sites have a working index?
They are 2 sites (2 WP installations, 2 index.css, 2 different themes). The one with Storefront works superb.
I’d check the Relevanssi settings: are the correct post types being indexed, is the index complete?
Mikko,
Thank you for all your work in this plugin, but unfortunately I can’t seem to make this work on my site. I have one blog post that is over 45,000 words and relevansi can’t seem to find that blog post at all. It can’t find anything relevant to the search terms I type in. I have blog posts with the word RV in the title and it doesn’t display them. I have another blog post called travel excuses and relevansi only displays my about page. I have been all over your knowledgebase center, forum, youtube, google and relevansi settings trying to figure this out today. Can you please help? If I can’t get it to work I am going to have to uninstall it and look for something else. My site is aowanders.com
Adam, the word “RV” cannot be found, because the shortest words Relevanssi indexes by default are three letters long. See the advanced indexing settings, there’s a setting you can use to make Relevanssi index two-letter words.
But looks like you’ve already moved on to SearchIQ?
I’ve had this issue with only the Yoast plugin installed, and not Yoast Local SEO.
I tried this fix and it worked, but it caused a fatal error on the front end of the website.
The fatal error came from a WooCommerce price filter widget as it was trying to combine the meta_query array with another array, but since the meta_query was no longer an array, it produced a fatal error.
I fixed the problem by updating the code to this:
add_filter(‘relevanssi_modify_wp_query’, ‘rlv_meta_fix’, 99);
function rlv_meta_fix($q) {
$q->set(‘meta_query’, array());
return $q;
}
I’m not sure if this will still fix the issue with Yoast Local SEO, but it worked for me with Yoast SEO and WooCommerce.