Created
March 30, 2015 19:37
-
-
Save srikat/f67df4e2b8a158d285e6 to your computer and use it in GitHub Desktop.
Display Archive pages by Modified Date in WordPress
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
add_action( 'pre_get_posts', 'sk_order_posts_by_modified' ); | |
/** | |
* Arrange Posts by last modified with the most recently updated ones at the top | |
* | |
* @author Sridhar Katakam | |
* @author Bill Erickson <- Boss | |
* @link http://www.billerickson.net/customize-the-wordpress-query/ | |
* @param object $query data | |
* | |
*/ | |
function sk_order_posts_by_modified( $query ) { | |
if( $query->is_main_query() && !is_admin() && is_archive() ) { | |
$query->set( 'orderby', 'modified' ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment