• Resolved darinadar

    (@darinadar)


    Hey! Is there any way to code in “Last Updated on [date]” to show right below the publish date? I’ve tried to change the code in content.php and template-tags.php but that didn’t quite work as expected. Any help is highly appreciated! Thanks!

    P.S: We want Google to pull the “Last Updated” date in SERP, otherwise it looks like our content is old and no longer relative, which is not true because we update it constantly.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Jarret

    (@jarretc)

    If you are not already using a child theme ( https://developer.www.ads-software.com/themes/advanced-topics/child-themes/ ) you should be using that. That said…..open up /template-parts/post/content.php and find

    if ( is_single() ) {
    				twentyseventeen_posted_on();

    Then just add the following directly below it

    echo "<br /> Last updated on " . the_modified_date( '', '', '', false);

    So the whole block of code should end up like this

    if ( 'post' === get_post_type() ) {
    			echo '<div class="entry-meta">';
    			if ( is_single() ) {
    				twentyseventeen_posted_on();
    				echo "<br /> Last updated on " . the_modified_date( '', '', '', false);
    			} else {
    				echo twentyseventeen_time_link();
    				twentyseventeen_edit_link();
    			};
    			echo '</div><!-- .entry-meta -->';
    		};
    Thread Starter darinadar

    (@darinadar)

    It worked! Thanks a lot Jarret, you’re the best! ??
    Just a quick question while I still have you here, is there any way to show only one date: either the publish date or the last updated date (if the post has been updated)?

    Again, thanks a lot for your time!!!

    Jarret

    (@jarretc)

    twentyseventeen_posted_on() is already adding the date/author line so that needs to be removed and then you can just do something like the following

    if ( is_single() ) {
    				echo "<br /> Last updated on " . the_modified_date( '', '', '', false) . " by " . get_the_author();

    the_modified_date() will use either the last modified date or if not modified it’ll use the initial date the post was created on

    Thread Starter darinadar

    (@darinadar)

    Thank you a million times, Jarret! ??

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Add “Last Updated on” to posts’ is closed to new replies.