• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer

WittySparks

Ignite Your Thoughts

  • Topics
    • Technology
    • Business
    • Marketing
    • Education
    • Healthcare
    • Travel & Tourism
    • Entertainment
    • Guides
    • Tutorials
  • Reviews
  • Newsletter
  • Contact Us

How to display Latest Updated Date and Time in WordPress posts

Do you have a blog with live posts?
or Do you have some posts or articles which require frequent updates?
or else Do you have articles which are more of resources and you keep updating the same with new resources quite often?

Then its must to mention the last modified date and time or last updated date and time or show the latest update time and date for a WordPress post.

As you know most of the WordPress themes come with Date Published in article or post page. But the WordPress blogs containing frequent updated content or resources page or live blogs etc. the last updated date-time or last modified date time plays a key role.

Also this helps a lot in SEO (Search Engine Optimization) as search engines highlight or feature the most popular and recently modified or updated pages and helps you to bring the relevant traffic.

Just follow this code and update your WordPress themes files or templates accordingly.

In our case we are using Twenty Fourteen theme, so the file which we need to edit or modify is:
wp-content / themes / twentyfourteen / inc / template-tags.php

In template-tags.php page look for the following function twentyfourteen_posted_on() and modify the same as below:

function twentyfourteen_posted_on() {
	if ( is_sticky() && is_home() && ! is_paged() ) {
		echo '' . __( 'Sticky', 'twentyfourteen' ) . '';
	}

  $post_time = get_the_time('U');
  $post_modified_time = get_the_modified_time('U');
  if ($post_modified_time >= $post_time + 86400) :
	// Set up and print post meta information.
  	printf( '%3$s and is last updated on %5$s %7$s',
  		esc_url( get_permalink() ),
  		esc_attr( get_the_date( 'c' ) ),
  		esc_html( get_the_date() ), 
  		esc_attr( get_the_modified_date( 'c' ) ),
  		esc_html( get_the_modified_date() ),
  		esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
  		get_the_author()
  	);
  else :  
	// Set up and print post meta information.
  	printf( '%3$s %5$s',
  		esc_url( get_permalink() ),
  		esc_attr( get_the_date( 'c' ) ),
  		esc_html( get_the_date() ), 
  		esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
  		get_the_author()
  	);
  endif;

}

If you are not using Twenty Fourteen theme and have your own custom theme, then look for the specified code in the single.php page or functions.php page, mostly it would be single.php which you need to edit.

Once you are at the respective code, have the following snippet:

$post_time = get_the_time('U');
$post_modified_time = get_the_modified_time('U');
if ($post_modified_time >= $post_time + 86400) {
echo "and last modified on ";
the_modified_time('F jS, Y');
echo " at ";
the_modified_time();
}

Hope this helped fellow blogger out there, why not share your snippet in case you coded it differently which meets your sites criteria.

Related Articles

  • Modifying WordPress to Allow website Authors to choose the Related Posts
  • Want to know if your PHP pages in Google index worthy? Here are a few core aspects to know
  • Internal Server Error in WordPress Blog with WP Super Cache

November 10, 2014 by Sravan Kumar Kandagatla Tagged With: PHP, Wordpress

Previous Post: « How Social Media makes it easier to build Your Brand
Next Post: 6 Adventure Vehicles You Won’t Believe Exist »

Primary Sidebar

Search

Recently Published

  • Most Effective 2021 Marketing Tactics for MLM Business
  • 9 ways to deal with the pressure of college and part-time work
  • Yoga for Constipation: Channelising the Power of Asanas
  • 20 Actionable Email Marketing Tips To Boost Your Results
  • Art Print makes Your Life Colourful

Random Reads

Technological Innovations in Entertainment

9 Low-Cost Ways to Overpower Your Competitors Online

If you have a little extra time; there are some really efficient ways to market your products at very reasonable rates!

Machine Learning and Data Science

Role of Machine Learning in Data Science

Our future relies on the technologies like machine learning and artificial intelligence which are currently soaring across the digital lake.

Tips for financial freedom

Financial Freedom Checklist – Cover these 10 Things in Life to Live It Fully

Keep knocking off the checklist shared and you would get closer to financial freedom and will start living life fully.

Parse Server

Parse is Closing Down: Try other Alternatives

The news of shutting down of Parse stunned the entire community of developers. Architects consider Parse to be a useful way to deal with model and deploy an application quickly.

Footer

Search

  • About Us
  • Contact Us
  • Privacy Policy
  • Affiliate Disclosure