Skip to content

Instantly share code, notes, and snippets.

@wplit
Last active December 17, 2019 21:29
Show Gist options
  • Select an option

  • Save wplit/5b537d57d7197184afe39425fdf13bf9 to your computer and use it in GitHub Desktop.

Select an option

Save wplit/5b537d57d7197184afe39425fdf13bf9 to your computer and use it in GitHub Desktop.
change order of default query
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