Reputation: 8329
I was wondering if anyone knows an effective way of displaying the last modified date on a Wordpress site.
I'm not interested in the last modified date of a single post or page, but in a date (and maybe time) that shows the last time ANY modification was made on a site.
For example:
I'm aware of the the_modified_date() and the get_the_modified_date() functions, but I'd like to effectively show the latest from all of the modified content (pages, posts, custom post types, etc.)
Thank you for your suggestions in advance!
Upvotes: 1
Views: 2385
Reputation: 318
You could query the most recently updated posts and pages, then pull out the updated date from there. Try something like this.
$recently_updated_posts = new WP_Query(array(
'post_type' => array('any'),
'posts_per_page' => 1
'orderby' => 'modified',
'no_found_rows' => true, // speed up query when we don't need pagination
));
Then, you can use the $recently_updated_posts
in the standard WordPress loop and have access to the_modified_date()
and the get_the_modified_date()
functions.
Upvotes: 1