Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Order Posts by modified date on Archive pages.
<?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
You can’t perform that action at this time.