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

The New Apple Music Features to Definitely Try in 2021

Apple Music is a nice app but it is not the most loved app, even among Apple users. The wide range of...

Best Free News Apps for iPhone and iPad in 2021

The year isn’t going as we expected, we are still living through a pandemic and all the problems of the world didn’t...

Best Apps to Hide Pictures & Videos on Your Phone

Privacy is important in everyone’s life, the intensity might change but no one wants to share everything with the world. Even the...

5 Best Health Apps for a Healthy Lifestyle for Everyone in 2021

Times have changed, but the only thing that has remained constant is the need for a healthy lifestyle. Various factors contribute to...

The Most Exciting Features of Apple iOS 14.5 for iPhone and iPad

The Most Exciting Features of Apple iOS 14.5  Apple tries to bring something new and better with every iOS...

Related Stories

Leave A Reply

Please enter your comment!
Please enter your name here