Created
October 22, 2020 09:05
-
-
Save jchristopher/433280821f91dbb826bc7e815d16622e to your computer and use it in GitHub Desktop.
Sort SearchWP results in alphabetical order
This file contains hidden or 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 | |
// Sort SearchWP results in alphabetical 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_title'; | |
}, 'ASC', 1 ); | |
$mods[] = $mod; | |
return $mods; | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment