Skip to content

Instantly share code, notes, and snippets.

@jchristopher
Last active May 7, 2019 15:38
Show Gist options
  • Save jchristopher/a57ca0426be3ca9676e2 to your computer and use it in GitHub Desktop.
Save jchristopher/a57ca0426be3ca9676e2 to your computer and use it in GitHub Desktop.
Tell SearchWP to return results in a random order (as opposed to ordered by relevance)
<?php
function my_searchwp_return_orderby_random( $random, $engine ) {
// if it's not the default search engine, have results be random
if ( 'default' !== $engine ) {
$random = true;
}
return $random;
}
add_filter( 'searchwp_return_orderby_random', 'my_searchwp_return_orderby_random', 20, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment