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


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

Available since: 1.4.8


View Parameters »

SearchWP was designed to be a relevance-based, keyword weighted search engine. By default returned results are based on a combination of relevance (determined by SearchWP) and keyword weight (determined by you via the settings) but there may be times where you want to use SearchWP’s intelligence to retrieve a results pool but have the returned results ordered by date. Using this hook you can make that happen.

Example: to have results from all search engines ordered by date, add the following to your theme’s functions.php:

// ALWAYS return search results ordered by date
add_filter( 'searchwp_return_orderby_date', '__return_true' );
view raw gistfile1.php hosted with ❤ by GitHub

Example: to conditionally return results ordered by date depending on search engine name, add the following to your theme’s functions.php:

function my_searchwp_return_orderby_date( $order_by_date, $engine ) {
// for the Default engine (only!) we want to return search results by date
if ( 'default' == $engine ) {
$order_by_date = true;
return $order_by_date;
add_filter( 'searchwp_return_orderby_date', 'my_searchwp_return_orderby_date', 10, 2 );
view raw gistfile1.php hosted with ❤ by GitHub


Parameter Type Description
$order_by_date Boolean

Whether the results are ordered by date instead of keyword weight

$engine String

The name of 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