General Topics

Display Post Update Date In WordPress

Display Post Update Date In WordPress

Read here how to display post update date in WordPress? Because it’s a good CMS which is use for different purposes like Blogs or Business sites. While you hit publish button in WordPress you look the date on the upper side of your post. That’s the date which is a most powerful factor in SEO. If you see SERPs then a date will show in post snippet. How to show Date From Google Search Results? So here I will tell you how to display post update date in your WordPress post. So the search engine picks post update date instead of published date.

Understand About Publish Date And Update Date

Just try to understand about publish dated and update date. Just see here if you publish a post on dated 09-October-2016. After it makes some changes on 15-October-2016 in WordPress then Google will pick 09-October-2016. And that’s not good in regarding SEO. So we will display post update date in WordPress post. So the search engine will pick that date. Because it will tell to Search Engine post updated date.

By the way, there are many plugins available in the market like WordPress “Last Modified Date”. But I will suggest you don’t use plugins in WordPress. Because it will make your site slow. So now I am sharing a trick about WordPress post. By following this trick you will able to display post update date in WordPress? Read also How To Setup CloudFlare Free CDN For A Website?

Display Post Update Date In WordPress

For that purpose, you need to trace out some files like as:

  • index.php
  • single.php
  • page.php

How to access index.php, single.php and page.php in WordPress?

Now try to understand how to access the index.php, single.php and page.php in WordPress. By the way, you can access these files from WordPress dashboard. Just click on Appearance » Editor.

Theme editorNow you will find above files.

Now just explore that code from above files after open it.

<?php the_modified_time('F jS, Y');?>

Keep in mind every theme uses different format so don’t search exact code, just search like that.

Now replace with this code.

<?php $u_time = get_the_time('U');
$u_modified_time = get_the_modified_time('U');
if ($u_modified_time >= $u_time + 86400) { 
echo "and last modified on "; 
the_modified_time('F jS, Y'); 
echo " at "; 
the_modified_time(); 
echo ", "; } ?>

Display Post Update Date In WordPress With Second Method

If you have failed to trace the above code. Then the below code in your function.php after closing php ?> code.

Theme editor

Next step to search function.php and place below code in this file like shown in the picture.

Open Function.php

<?php
function wpt_post_updated($d = '') {
 if ( '' == $d )
 $the_time = get_post_modified_time(get_option('date_format'), null, null, true);
 else
 $the_time = get_post_modified_time($d, null, null, true);
 
 return apply_filters( 'wpt_post_updated', $the_time, $d );
 }
add_shortcode( 'post_updated', 'wpt_post_updated' );
//* Add Post Updated Date
add_filter('the_content', 'wpt_updated_date');
function wpt_updated_date($content) {
$wpt_updated_date= '<span style="font-style:normal; font-weight:bold;text-align:center;">Updated On: [post_updated]</span>';
if(is_single() && !is_home()) {
$content = $wpt_updated_date.$content;
}
return $content;
}
//* Add Post Updated Date In Meta
add_filter( 'tc_date_meta' , 'display_the_update_date');
function display_the_update_date() {
 return sprintf( '<a href="%1$s" title="updated %2$s" rel="bookmark"><time class="entry-date" datetime="%3$s">%4$s</time></a>' ,
 esc_url( get_day_link( get_the_time( 'Y' ), get_the_time( 'm' ), get_the_time( 'd' ) ) ),
 esc_attr( get_the_modified_date('F j, Y') ),
 esc_attr( get_the_modified_date('c') ),
 get_the_modified_date('F j, Y')
 );
}
?>

Function.php WordPress Location

Just see here a file named, function.php WordPress location? In the case of any error, you can leave your comment or code remove.
Log in your CPanel account.
Find File Manager by CTRL+F.

File Manager CPanel

Open this folder. You will find public html now click on it.

Public HTML folder
Now you will find wp-content open it.
WP Content Folder Through CPanel

Now open this folder which is showing in below picture.

Themes CPanel

Now select your active theme folder.

Current Theme

After open that folder you will get files now search out function.php file.

Function.php

For edit see the above side you will get edit button like that:

Edit File CPanel

I hope you have understood about how to display post update in Google SERPs.

Don’t forget to read:

  1. How To Make Website Speed Faster With WP Fastest Cache?
  2. Download YouTube Videos in Just a Second
  3. Improve Site’s Security Change Database Prefix
Show More

Global Blurb Team

“Global Blurb since 2015” Global Blurb providing information about SEO, Beauty, Health & Fitness, Interior designing, Fashion and ways of earning online without investing a penny. The blog designed to share ideas about different topics.

Want to contribute