Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Sort SearchWP Post, Page, and Custom Post Type Results by date in DESC order
<?php
// Sort SearchWP Post, Page, and Custom Post Type Results by date in DESC order.
add_filter( 'searchwp\query\mods', function( $mods ) {
$mod = new \SearchWP\Mod( \SearchWP\Utils::get_post_type_source_name( 'post' ) );
$mod->order_by( function( $mod ) {
return $mod->get_local_table_alias() . '.post_date';
}, 'DESC', 1 );
$mods[] = $mod;
return $mods;
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.