Created
June 27, 2024 09:29
-
-
Save bkno/5ff0e3f8dea322efebf6759c8844a207 to your computer and use it in GitHub Desktop.
Add Relevanssi search support to GenerateBlocks Query Loop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Add Relevanssi search support to GenerateBlocks Query Loop. | |
* Needed if you create a custom search results template using | |
* GeneratePress Elements and GenerateBlocks. | |
*/ | |
add_filter( 'generateblocks_query_loop_args', function( $query_args, $attributes ) { | |
/* Search query */ | |
if (! is_admin() && ! empty( $query_args['s'] ) ) { | |
$query_args['relevanssi'] = true; | |
} | |
return $query_args; | |
}, 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment