How to Display the Last Updated Date of Your Posts in WordPress
Check Out More At: WP Beginner
WordPress: Best WordPress Plugins | WordPress Tutorials
How to Display the Last Updated Date of Your Posts in WordPress
Product Image | Product Name / Primary Rating / Price | Primary Button / Description |
---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Elementor is an amazing website builder plugin for WordPress. Elementor makes it easy to create beautiful and high converting websites yourself without having to learn code.
Gravity Forms is a WordPress plugin that creates powerful forms quickly and easily, with drag-and-drop fields, custom notifications and confirmations, and custom styling capability.
Kadence Theme is a powerful, intuitive and flexible WordPress theme that offers an expansive set of features and customization options.
It includes a robust page builder, beautiful design options, mobile-friendly responsiveness, powerful SEO tools and optimized performance for faster loading times.
It's perfect for creating stunning websites without needing to write any code.
Cloudways is a managed cloud hosting platform that simplifies cloud infrastructure deployment and management.
It provides an intuitive dashboard, automated backups and optimized stack for speedy performance. It also provides 24x7 support with multiple server locations, enabling businesses to host their applications quickly and securely.
It’s no secret that keeping your content fresh is vital to a successful website. Search engines love to see new content, and visitors appreciate knowing that they’re reading up-to-date information. For these reasons, it’s a good idea to display the last updated date of your posts in WordPress.
Fortunately, this is fairly easy to do with a little bit of code. Simply add the following to your functions.php file:
function wp_last_updated_date($format = ‘F j, Y’) {
$last_updated = get_the_modified_date($format);
echo “This post was last updated on ” . $last_updated;
}
Once you’ve added that code, you can display the last updated date of your posts by simply calling the wp_last_updated_date() function where you want it to appear. For example, you could add it to your single.php file like this:
if ( have_posts() ) {
while ( have_posts() ) {
the_post();
the_content();
wp_last_updated_date(‘F j, Y’);
} // end while
} // end if
?>
Of course, you can change the format of the date to suit your needs. For more information on date and time formatting in PHP, check out the docs at php.net/manual/en/function.date.php.
Do you have any questions about how to display the last updated date of your posts in WordPress? Let us know in the comments below!