Last active
November 14, 2017 12:25
-
-
Save rickrduncan/3733f1073f074642ab6ae1c257672ff6 to your computer and use it in GitHub Desktop.
Order Posts by modified date on Archive pages.
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 | |
//* Do NOT include the opening php tag above | |
/** | |
* Sort Posts by "last modified date" | |
* | |
*/ | |
add_filter('posts_orderby', 'b3m_order_posts_by_mod_date', 999); | |
function b3m_order_posts_by_mod_date($orderby) { | |
if ( is_archive() ) { | |
$orderby = "post_modified_gmt DESC"; | |
} | |
return $orderby; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment