How to show ‘Last Update’ date for posts instead of ‘Published’ date?
-
Hello,
I want to make my blog show ‘Last Update’ date instead of ‘Published’ date for my blog posts, as I found publish date of blog posts is shown on Google search result pages, this may not good for posts that are published years ago, as people don’t want to read old articles.
So I want to change the text “published on …” under the blog title to “updated on…”, and whenever I update a post, the date of the post will get updated.
And I want the date to be shown on both blog post and search engine result page.A perfect example is the site Lifewire.com, all of its blog posts only show update date, and the update date is also shown on Google search result page instead of showing published date.
I tried to directly change the date at a dedicated section in the right sidebar of the post edit panel, and replace the code for the text ‘published on’ with ‘updated on’, but in that way my old post will be moved to the first row of the blog loop when I update it, I don’t want that, I just want the date be updated but let it remain in the original position in the blog loop.
So can anybody help me figure out a way to achieve this? Thanks in advance!
Below is the related code I found in content-single.php and template-tags.php, I’m a beginner on coding, so I don’t know how to tweak these code to achieve what I want.
<div class="entry-meta"> <?php puresimple_posted_on(); ?> </div><!-- .entry-meta --> function puresimple_posted_on() { $time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time>'; if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) { $time_string .= '<time class="updated" datetime="%3$s">%4$s</time>'; } $time_string = sprintf( $time_string, esc_attr( get_the_date( 'c' ) ), esc_html( get_the_date() ), esc_attr( get_the_modified_date( 'c' ) ), esc_html( get_the_modified_date() ) ); $posted_on = sprintf( __( 'Published on %s', 'pure-simple' ), '<a href="' . esc_url( get_permalink() ) . '" rel="bookmark">' . $time_string . '</a>' ); $byline = sprintf( _x( 'by %s', 'post author', 'pure-simple' ), '<span class="author vcard"><a class="url fn n" href="' . esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ) . '">' . esc_html( get_the_author() ) . '</a></span>' ); echo '<span class="posted-on">' . $posted_on . '</span><span class="byline"> ' . $byline . '</span>';
- The topic ‘How to show ‘Last Update’ date for posts instead of ‘Published’ date?’ is closed to new replies.