How to Display “Last Updated” instead of “Published” Date

by default displays the date when a post was published to your website visitors. Plus it adds the date when the post was last updated in the code – for SEO and Schema Markup.

Published date is displayed in the front end
Both, published as well as updated dates are available in the markup.

If you want to display last updated date for the post to your visitors, use following custom code –

/**
 * Display only last modified date in the post metadata.
 *
 * @param String $output Markup for the last modified date.
 * @return void
 */
function your_prefix_post_date( $output ) {
  $output        = '';
  $format        = apply_filters( 'astra_post_date_format', '' );
  $modified_date = esc_html( get_the_modified_date( $format ) );
  $modified_on   = sprintf(
    esc_html( '%s' ),
    $modified_date
  );
  $output       .= '<span class="posted-on">';
  $output       .= '<span class="post-updated"> ' . $modified_on . '</span>';
  $output       .= '</span>';
  return $output;
}
add_filter( 'astra_post_date', 'your_prefix_post_date' );

 

It hides the published date and makes updated date visible.

Receive our product updates, customer gift & daily product reviews