Created
September 13, 2017 17:47
-
-
Save Garconis/f7400f7981297a93b6c9758a9352292b to your computer and use it in GitHub Desktop.
WordPress | Force search results to be in alphabetical order
This file contains 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 | |
function abc_search( $query ) { | |
if( $query->is_search && !is_admin() ) { | |
$query->set( 'orderby', 'title' ); | |
$query->set( 'order', 'ASC' ); | |
} | |
} | |
add_filter( 'pre_get_posts','abc_search' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment