Sort posts based upon last modification date

Posted under WordPress. Viewed 89 times.
Created on September 11, 2009. Last modified on January 19, 2010.

wordpressBecause I regularly update existing posts instead of writing new ones each time the contents needs to be changed, it would make sense to also show the last modified post first instead of alphabetically or by creation date. In order to do this some source code of the WordPress theme needs to be modified.

Update the index.php, search.php and archive.php files of your WordPress theme with the following code. Insert just before The Loop or update any already existing query_posts tags with this:

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

Leave a Reply