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.