Posted on

Gutenberg Full Site Editing

There’s something of a compatibility issue between Relevanssi and Gutenberg Full Site Editing. No results are found when you create a Query Loop to display the search results with Relevanssi enabled. The blank results happen because the post template block doesn’t use the Relevanssi results but instead uses a new WP_Query. Since Relevanssi still blocks the default search, this comes up empty.

For a straightforward solution, add this to your theme functions.php:

add_filter( 'relevanssi_search_ok', function( $ok, $query ) {
  if ( ! empty( $query->query_vars['s'] ) ) {
    $ok = true;
  }
  return $ok;
}, 10, 2 );

This function hooks to the relevanssi_search_ok filter hook. This hook fires because Relevanssi looks at the newly-created WP_Query, but since it’s not the main query for the template, Relevanssi doesn’t take over. This function instructs Relevanssi to take over as long as there’s a s parameter in the query and a search term exists.

Leave a Reply

Are you a Relevanssi Premium customer looking for support? Please use the Premium support form.

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.