Site logo

[Support request] Add the words ‘last updated:’ before the updated date (updated date filter)

Home Forums Support [Support request] Add the words ‘last updated:’ before the updated date (updated date filter)

Home Forums Support Add the words ‘last updated:’ before the updated date (updated date filter)

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #2485770
    Michael

    Hello,

    I have used the following filter to display only the ‘last updated date,’

    add_filter( ‘generate_post_date_show_updated_only’, ‘__return_true’ );

    However, I’d just like it to say Last updated: before the date. I looked at some support topics and saw some similar-ish topics, but it was about adding and editing different bits of codes together & I’m very much a novice, thus worried about crashing my site by editing!

    Is there a code I can use to replace add_filter( ‘generate_post_date_show_updated_only’, ‘__return_true’ ); that has the ‘last updated:’ text built into it?

    Thank you!

    #2485793
    David
    Staff
    Customer Support

    Hi there,

    you would need a separate snippet to add the label:

    
    add_filter( 'generate_post_date_output','tu_add_to_post_date' );
    function tu_add_to_post_date( $output ) {
        return '<span class=”date-label”>Last updated: </span> ' . $output;
    }
    #2485807
    Michael

    Hi David,

    Thank you for the quick reply.

    Do I just add this as a separate snippet and kept the current one as is?

    #2485819
    David
    Staff
    Customer Support

    Thats correct you need both, and you can add them together as a single snippet, heres that combined code with some comments for future reference:

    
    // show updated data only
    add_filter( 'generate_post_date_show_updated_only', '__return_true' );
    
    // add Last updated label to date
    add_filter( 'generate_post_date_output','tu_add_to_post_date' );
    function tu_add_to_post_date( $output ) {
        return '<span class=”date-label”>Last updated: </span> ' . $output;
    }
    #2485824
    Michael

    Perfect – thank you!

    #2485842
    David
    Staff
    Customer Support

    You’re welcome

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