Is there a way to list posts in the order in which they were modified?

For example;

A user posts 5 posts (#1 being the oldest and #5 being the newest), by default they would be listed with #5 being at the top, but say the user edited post #3 at a later date, is it possible to then list post #3 above #5 without manually changing the page attributes?

This is a secondary query by the way, using get_posts

1 Answer 1


If you use WP_Query you can set the orderby to modified and then the order to DESC and you'll be good to go. If it's not a custom query, you can just use the set() method on the default $wp_query global to do the same. Since get_posts() is just a wrapper for WP_Query, you can set the orderby parameter there if everything else is working and not change anything else.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.