Skip to content
This repository has been archived by the owner. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #1 from jjc16105/master
changes for sort order
  • Loading branch information
jmr06005 committed Aug 30, 2016
2 parents 227232c + 38f8386 commit d81c6c9
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions functions.php
@@ -1,4 +1,17 @@
<?php
//
// Order search results by post_date
//
function my_search_query( $query ) {
// not an admin page and is the main query
if ( !is_admin() && $query->is_main_query() ) {
if ( is_search() ) {
$query->set( 'orderby', 'post_date' );
$query->set( 'order', 'DESC' );
}
}
}
add_action( 'pre_get_posts', 'my_search_query' );

//
// Order search results by post_title
Expand Down

0 comments on commit d81c6c9

Please sign in to comment.