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
If you use
WP_Query
you can set theorderby
tomodified
and then the order toDESC
and you’ll be good to go. If it’s not a custom query, you can just use theset()
method on the default$wp_query
global to do the same. Sinceget_posts()
is just a wrapper forWP_Query
, you can set theorderby
parameter there if everything else is working and not change anything else.