Last active
December 17, 2019 21:29
-
-
Save wplit/5b537d57d7197184afe39425fdf13bf9 to your computer and use it in GitHub Desktop.
change order of default query
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
| add_action( 'pre_get_posts', 'search_filter' ); | |
| function search_filter($query) { | |
| if ( ! is_admin() && $query->is_main_query() ) { | |
| if ( $query->is_search ) { | |
| $query->set( 'order', 'ASC' ); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment