Erwin Mayer
← Writing

Computer science · Programmation 1 min

How to sort WordPress posts by modified date instead of published date?


Here is the simple solution. Simply use this:

<?php query_posts($query_string . '&orderby=modified&order=desc'); ?>

before where the Loop checks for posts:

<?php /* If there are any posts: */ 
if (have_posts()) ...
?>

It basically adds a condition to the Loop. Enjoy!


Comments

Live comments coming soon — Waline + Google/GitHub login. Until then, reach out via the contact page.