I want to retrieve the modification date of the latest post. To do this, first I get the latest post:
$latest_post = get_posts()[0];
Can I be certain that the returned object is always the latest post or are there circumstances where the order of objects returned by get_posts()
is different?
Yes and Maybe
Yes: According to https://developer.wordpress.org/reference/functions/get_posts/ the default is ordered by date in a descending order.
Maybe: But plugins may change the query through ie hook(s) pre_get_posts.
- https://developer.wordpress.org/reference/hooks/pre_get_posts/
- https://developer.wordpress.org/reference/classes/featured_content/pre_get_posts/