Note: You are viewing the documentation for Version 3View Version 4 Docs

Documentation

View the installation guide, browse the Knowledge Base, find out about SearchWP's many hooks, get support

Available since: 1.6

searchwp_return_orderby_random

View Parameters »

By default SearchWP will return results ordered by relevance (as determined by keyword weight defined by you in the SearchWP settings) but if you would instead like results to be returned at random you may add the following to your theme’s functions.php:

<?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 );
view raw gistfile1.php hosted with ❤ by GitHub

Parameters

Parameter Type Description
$random Boolean

Whether the results should be random

$engine String

The engine in use

Fix keyword search on your site. No coding required!

Now you can utilize all of the content that's gone unrecognized by native WordPress keyword search instantly with SearchWP

Get SearchWP