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

Do you wish to have to show final up to date date in your posts in WordPress? Some web pages ceaselessly replace their posts and would love to display customers when the article was once final up to date. In this newsletter, we can display you the way to simply show the final up to date date of your posts in WordPress.

When You Need Last Updated Date for Posts in WordPress?

Most WordPress subject matters generally display the date when a submit was once final revealed. This is ok for many blogs and static web pages.

However, WordPress may be utilized by web pages the place previous articles are ceaselessly up to date (like ours). This final up to date date and time is essential knowledge for the ones publications.

The maximum commonplace instance is information web pages. They continuously replace previous tales to display new trends, upload corrections, or media information. If they simply added the revealed date, then their customers would leave out the ones updates.

Many fashionable blogs and internet sites don’t display any date on their articles. This is a nasty observe and also you must by no means take away dates out of your weblog posts.

Having mentioned that, let’s see how to simply show final up to date date in your posts in WordPress.

Video Tutorial

If you don’t like the video or want extra directions, then proceed studying.

Displaying Last Updated Date in WordPress

This instructional calls for you to upload code to your WordPress information. If you haven’t achieved this ahead of, then we propose you to have a look at our information on how to reproduction paste code in WordPress.

Method 1: Show Last Updated Date Before Post Content

You will want to upload this code to your theme’s purposes.php record or a site-specific plugin.


serve as wpb_last_updated_date( $content material ) {
$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 magnificence="last-updated">Last up to date on '. $updated_date . ' at '. $updated_time .'</p>';  
} 

    $custom_content .= $content material;
    go back $custom_content;
}
add_filter( 'the_content', 'wpb_last_updated_date' );

This code exams to see if a submit’s revealed date and final changed dates are other. If they’re, then it shows final changed date ahead of the submit content material.

You can upload customized CSS to taste the look of the final up to date date. Here is somewhat CSS that you’ll use as start line:


.last-updated {
    font-size: small;
    text-transform: uppercase;
    background-color: #fffdd4;
} 

This is the way it appeared on our demo web site.

Last updated date in post content

Method 2: Add Last Updated Date in Theme Templates

This manner calls for you to edit particular WordPress theme information. Many WordPress subject matters now use their very own template tags which outline how those subject matters display submit meta knowledge like date and time.

Some subject matters additionally use content material templates or template portions to show posts.

Few more effective subject matters will use unmarried.php, archive.php, and different template information to display content material and meta knowledge.

You can be searching for the code answerable for exhibiting the date and time. You can then both substitute that code with the following code, or upload it proper after your theme’s date and time code.


$u_time = get_the_time('U'); 
$u_modified_time = get_the_modified_time('U'); 
if ($u_modified_time >= $u_time + 86400) { 
echo "<p>Last changed on "; 
the_modified_time('F jS, Y'); 
echo " at "; 
the_modified_time(); 
echo "</p> "; } 

This is the way it appeared on our demo website:

Last updated date in post meta

We hope this newsletter helped you learn the way to show final up to date date of your posts in WordPress. You might also need to see our record of most precious time saving WordPress shortcuts.

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

Recent Articles

How To Check Whether Someone Blocked You On Instagram

All social media platforms including Instagram do not notify people when they get blocked by a user. But when someone’s post and...

Free Apps Make Money through These Innovative Ways

Have you always wondered why are some apps available to you free of cost? If you want to know how apps make...

How To Completely Remove Google Account From Chrome Browser

Google Chrome when used with your personal Google account lets you keep the data in sync with all your devices. Your YouTube...

How To Know If Your Android Smartphone Is Hacked And How To Fix It!

One of the worst nightmares you can ever witness is realizing that your Android Smartphone Is Hacked. Yes, you're allowed to be...

How to Fix Google Drive Not Downloading Files After Zipping

Google Drive is one of the most convenient and easy-to-use file storage services. It allows us to store or host files online,...

Related Stories

Leave A Reply

Please enter your comment!
Please enter your name here