I’m looking forward to display, somewhere in the homepage of a WP site, a legend saying:
Last updated: XX/XX
by grabbing the date from the most recent post, but not showing any of its content, just the date.
Is there any quick way to do this?
I’m looking forward to display, somewhere in the homepage of a WP site, a legend saying:
Last updated: XX/XX
by grabbing the date from the most recent post, but not showing any of its content, just the date.
Is there any quick way to do this?
Comments are closed.
I would save an option on post save:
And retrieve it with a variant of the function provided by @G-M :
This way you:
wp_get_recent_posts
),get_option
query,There are different way to do this.
The easiest, in my opinion is to use
wp_get_recent_posts
to retrieve the last post and the print the post modified date.Wrapping it in a function make it flexible and reusable. In your
functions.php
you can put:Then you can use it like so:
The argument
$format
let you choose a different date format for the date see here to choose one. If nothing is passed, the format set in WP options is used.