Tuesday, December 1, 2020
Home Blogging How to Display the Last Updated Date of Your Posts in WordPress

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

Do you need to show last updated date in your posts in WordPress? Some web sites repeatedly replace their posts and wish to present customers when the article was final up to date. On this article, we are going to present you methods to simply show the last updated date of your posts in WordPress.

When You Want Last Updated Date for Posts in WordPress?

Most WordPress themes normally present the date when a put up was final revealed. That is high-quality for many blogs and static web sites.

Nonetheless, WordPress can be utilized by web sites the place previous articles are repeatedly up to date (like ours). This last updated date and time is necessary info for these publications.

The most typical instance is information web sites. They usually replace previous tales to point out new developments, add corrections, or media information. In the event that they solely added the revealed date, then their customers would miss these updates.

Many widespread blogs and web sites don’t present any date on their articles. It is a unhealthy apply and you must by no means take away dates out of your weblog posts.

Having stated that, let’s see methods to simply show last updated date in your posts in WordPress.

Displaying Last Updated Date in WordPress

This tutorial requires you so as to add code to your WordPress information. When you haven’t executed this earlier than, then we advocate you to have a look at our information on methods to copy paste code in WordPress.

Methodology 1: Present Last Updated Date Earlier than Publish Content material

You have to so as to add this code to your theme’s capabilities.php file or a site-specific plugin.

1
2
3
4
5
6
7
8
9
10
11
12
13
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' );

This code checks to see if a put up’s revealed date and final modified dates are completely different. If they’re, then it shows final modified date earlier than the put up content material.

You may add customized CSS to type the looks of the last updated date. Here’s a little CSS that you should use as start line:

1
2
3
4
5
.last-updated {
    font-size: small;
    text-transform: uppercase;
    background-color: #fffdd4;
}

That is the way it regarded on our demo web site.

Methodology 2: Add Last Updated Date in Theme Templates

This methodology requires you to edit particular WordPress theme information. Many WordPress themes now use their very own template tags which outline how these themes present put up meta knowledge like date and time.

Some themes additionally use content material templates or template components to show posts.

Few less complicated themes will use single.php, archive.php, and different template information to point out content material and meta info.

You can be searching for the code accountable for displaying the date and time. You may then both change that code with the next code, or add it proper after your theme’s date and time code.

1
2
3
4
5
6
7
8
$u_time = get_the_time('U');
$u_modified_time = get_the_modified_time('U');
if ($u_modified_time >= $u_time + 86400) {
echo "<p>Last modified on ";
the_modified_time('F jS, Y');
echo " at ";
the_modified_time();
echo "</p> "; }

 

We hope this text helped you learn to show last updated date of your posts in WordPress. You might also need to see our record of most helpful time saving WordPress shortcuts.

You May Also Like : How to Disable Trackbacks and Pings on Existing WordPress Posts

If you liked this article, make sure to hit the bell for getting our latest updates and share this article with your friends in every social media platforms.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -

Most Popular

How to make money with Toluna surveys

Toluna is most well-known for its surveys, however there are an entire host of different methods to earn rewards on the location. Our assessment...

6 Best Free Alternatives To Camtasia 2020 For Mac And Windows

I really like Camtasia and have been an avid person of Camtasia ever since 2012. Recently, the Camtasia workforce launched the 2019 model of Camtasia which...

List of Travel Affiliate Programs For Travel Bloggers

For me, touring is freedom. If you're a journey blogger, I offer you a standing ovation. Being a digital nomad, I perceive how powerful it's to weblog whereas touring. I additionally...

Social Warfare Review: Explode your Social Shares

Everybody is aware of that having social media sharing buttons is important for each weblog within the Blogosphere. Why? Well, social media sharing buttons assist us...

Recent Comments