[Support request] How to set this place as “Last updated”

Home Forums Support [Support request] How to set this place as “Last updated”

Home Forums Support How to set this place as “Last updated”

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #2347298
    Trạng

    Hi there, I want to set the default post date into the text “Last updated” like this screenshot

    The site in example using Marketer “site library template”. So in case I want to use the “Scribe” template in site library how can I set it?

    #2347745
    Ying
    Staff
    Customer Support

    Hi Trang,

    The site you linked is using the updated date.

    Scribe template is using a block element - page hero for the single posts, the post date can be switched to the updated date easily within the block element like this:
    https://www.screencast.com/t/mg9jB40ZtMcw

    #2348162
    Trạng

    Hi Ying, thank you.

    But what if I don’t want to use the “page hero block element” that’s available on Scribe and only want to use simple title & updated date like the site in sample? Can you advice? Thank Ying 🙂

    #2348169
    Fernando
    Customer Support

    Hi Trang,

    You can use a Filter. Try adding this Snippet:

    add_filter( 'generate_post_date_output', function( $output, $time_string ) {
        $time_string = '<time class="entry-date published" datetime="%1$s" itemprop="datePublished">Published on: %2$s</time>';
    
        if ( get_the_date() !== get_the_modified_date() ) {
            $time_string = '<time class="entry-date updated-date" datetime="%3$s" itemprop="dateModified">Last Updated on: %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() )
        );
    
        return sprintf( '<span class="posted-on">%s</span> ',
            $time_string
        );
    }, 10, 2 );

    Adding PHP: https://docs.generatepress.com/article/adding-php/#code-snippets

    #2348170
    Trạng

    Thank Fernado, I will try & give a feedback later! Nice day, friend!

    #2348171
    Fernando
    Customer Support

    You’re welcome Trang! Nice day to you as well!

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