Support » Theme: Poseidon » Display Last Updated Date Instead of Published Date

  • Resolved clydebank1

    (@clydebank1)


    Hello,

    I want to display the last updated date instead of the original published date on my posts. I also want to have this last updated date be reflected in the Google Snippet instead of the original published date.

    Can I add the following to the theme functions.php file?

    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' ) ) );
            $date = $the_modified !== $the_time ? $last_modified : get_post_time( 'M j, Y' );
     
            return $date;
        }
    }
    add_action( 'get_the_date', 'et_last_modified_date_blog' );
    add_action( 'get_the_time', 'et_last_modified_date_blog' );

    Thank you!

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Display Last Updated Date Instead of Published Date’ is closed to new replies.