WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question
up vote 1 down vote accepted

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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