• About
  • What I’m Doing Now

Nancy Lin's Blog

About business, marketing & misc.

  • Business
  • Software Development
  • Dyslexia
  • Momming
  • Everything Else
You are here: Home / Everything Else / Adding ‘Updated Date’ & ‘Published Date’ for Divi Theme

Adding ‘Updated Date’ & ‘Published Date’ for Divi Theme

Published On February 21, 2019, Last Updated On February 21, 2019 by Nancy Lin

People Want the Latest Info

A very useful feature to have for your blog is to show both the Published Date and the Last Updated Date in each post. This can tell the reader how up-to-date the information is.

Last Updated Date signals to the reader how relevant the information is.

I feel being able to see Last Updated Date will become more important as time goes on and people seeking only to consume the most up-to-date information. They will often choose to read only the most recent article. So having both of the dates is an inexpensive way to keep your blog 'new'.

Simple Project

Luckily Divi Theme provides this great article on how to add various formats to your fuction.php file. You can find this file in your Child Theme's folder.

Access your FTP via FileZilla or similar software.

Copy My Code

For those that are not comfortable putting together their own code combination from the article you can just take my code. This code below will get you both the Published Date and the Last Updated Date.

//Adding 'last updated date' & 'published date' to blog post
function et_last_modified_date_blog( $the_date ) {
if ( 'post' === get_post_type() ) {
$the_time = get_post_time( 'His' );
$the_modified = get_post_modified_time( 'His' );

$last_modified = sprintf( __( 'Last updated %s', 'Divi' ), esc_html( get_post_modified_time( 'M j, Y' ) ) );
$published = sprintf( __( 'Published on %s', 'Divi' ), esc_html( get_post_time( 'M j, Y' ) ) );

$date = $the_modified !== $the_time ? $last_modified . ' | ' . $published : $published;

return $date;
}
}
add_action( 'get_the_date', 'et_last_modified_date_blog' );
add_action( 'get_the_time', 'et_last_modified_date_blog' );
//end "last udpated date" & 'published date' for blog post

Powered by StoryChief

Related

Filed Under: Everything Else Tagged With: Divi Theme Modifications

Subscribe to Blog

I send out monthly email when there are new posts.

google badge Subscribe with Google


linkedin badge Subscribe with Linkedin


or subscribe by email

* indicates required

About Nancy Lin

Businesses

Projects

Search

Connect

  • LinkedIn
  • Twitter

Copyright © 2023 ยท Nancy Lin