Display the Last Updated Date of Your Posts in WordPress

Do you want to display the last updated date of your article in your Wordpress post or page? In this article, we will show you how to easily display the last updated date of your posts in WordPress.

In this tutorial you will need to add code to your Wordpress files. We recommend you to install "My Custom Functions" plugin in your Wordpress site so you don't touch your core files.



1. Add this code block of code to  My Custom Functions



function wpb_last_updated_date( $content ) {
        $u_time = get_the_time('U');
        $u_modified_time = get_the_modified_time('U');
        if ($u_modified_time >= $u_time + 86400) {
                $updated_date = get_the_modified_time('F jS, Y');
                $updated_time = get_the_modified_time('h:i a');
                $custom_content .= '<p class="last-updated">Last updated on '. $updated_date .  ' at '. $updated_time .'</p>';
        }
        $custom_content .= $content;
        return $custom_content;
}
add_filter( 'the_content', 'wpb_last_updated_date' );

 2. Click Save Changes button

This is how it looked on our demo website.

If the post's published date and last modified date are different, it displays the last modified date before the content.

You can also add CSS style to the text, see my samply CSS code below

.last-updated {
    font-weight: bold;
    color: blue;
    font-size: 12px;
}



If you liked this article, then please subscribe to our YouTube Channel for our video tutorials. You can also find us on Twitter and Facebook.



Comments

Popular posts from this blog

Photoshop Tutorials Edit a Memorable BG Same Picture Style

How to Add a Lens Flare to an Image in Adobe Photoshop