Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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
add comment

1 Answer

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
add comment

Your Answer

 
discard

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.