How to Display the Last Updated Date of Your Posts in WordPress

by enablewebsitedesign


How to Display the Last Updated Date of Your Posts in WordPress

As a WordPress admin, you may wish to display the last updated date of your posts to the public. This can be useful for various purposes such as indicating to the readers if a post is still relevant or to attract attention to a recent update. Fortunately, WordPress provides an easy way to do this.

Displaying your Last Updated Date in WordPress

Firstly, you will need to open the WordPress Admin sidebar by hovering over the left-hand side of the dashboard. From there, go to Appearance -> Editor. On this page, you should select the Theme Functions (functions.php) option from the right-hand sidebar.

Once you are in the functions.php file, you should add the below code snippet to the end of the document.

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');
        $custom_content .= '

Last updated on ‘. $updated_date . ‘ at ‘. $updated_time .’

$custom_content .= $content;
return $custom_content;
add_filter( ‘the_content’, ‘wpb_last_updated_date’ );

This code will display the last updated date of the post beside your blog post content. If you wish to add other styling to the text such as color or font, then you should add CSS to your functions.php as well.

Once you have done this, you should save the file and review the post to ensure that the last updated date is being displayed correctly. Congratulations, you have successfully displayed the last updated date of your posts in WordPress!

Need a website for your business?

We offer affordable WordPress website design services that helps you create a powerful online presence. Our team of experienced designers has extensive knowledge of WordPress and can create a custom wordpress website design with elementor pro that perfectly reflects your brand and message. We will work closely with you to understand your needs and goals, and provide recommendations for design and functionality based on our expertise.

Get Website Design Services

In addition to design, we can also provide optimization services for search engines, responsive design for mobile devices, and integration with social media platforms. Our goal is to create a website that not only looks great, but also delivers results for your business or organization. Let us help you take your online presence to the next level with our professional WordPress website design services.

You may also like

Leave a Comment