[Resolved] Post “Updated on” to reflect ModifiedTime

Home Forums Support [Resolved] Post “Updated on” to reflect ModifiedTime

Home Forums Support Post “Updated on” to reflect ModifiedTime

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #2477889
    Ivaylo

    Hi,
    I’m using this code:
    add_filter( ‘generate_post_date_output’,’tu_add_to_post_date’ );
    function tu_add_to_post_date( $output ) {
    return ‘<span class=”date-label”>Updated on </span>’ . $output;
    }

    to show the date the post is updated. But it shows the published time ( PublishedTime ) instead the one I updated the post ( which I can see in ModifiedTime )

    #2477893
    Ivaylo

    See the attached screenshot:

    #2477894
    Ivaylo
    #2477982
    David
    Staff
    Customer Support

    Hi there

    can i see the issue on your site ?

    #2478102
    Ivaylo

    Sure, link is below:
    I just updated this post ( 30.12.2022 ), but it still showing the date 22.12.2022 when I edited the post and hit Publish instead of Update.
    I want to show the date the post was updated as it is noted in ModifiedTime in the schema/dev tools.

    #2478115
    David
    Staff
    Customer Support

    If you use the snippet provided here:

    https://docs.generatepress.com/article/generate_post_date_show_updated_only/

    Then GP Will only output a single date, either the published date or if the post has been modified it will show the updated date.

    #2478122
    Ivaylo

    So I should place all of the following in my functions.php:

    add_filter( ‘generate_post_date_output’,’tu_add_to_post_date’ );
    function tu_add_to_post_date( $output ) {
    return ‘<span class=”date-label”>Updated on </span>’ . $output;
    }

    add_filter( ‘generate_post_date_show_updated_only’, ‘__return_true’ );

    Because I want to have “Updated on” before the date.

    #2478124
    Ivaylo

    Is there a more elegant and shorter filter function for the above two?

    #2478127
    David
    Staff
    Customer Support

    Using those 2 snippets are as elegant as it gets ๐Ÿ™‚

    #2478128
    Ivaylo

    Thanks! Happy Holidays!

    #2478203
    David
    Staff
    Customer Support

    And Happy Holidays to you ๐Ÿ™‚

Viewing 11 posts - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.