[Resolved] Show last update date on posts and google results

Home Forums Support [Resolved] Show last update date on posts and google results

Home Forums Support Show last update date on posts and google results

Viewing 15 posts - 1 through 15 (of 24 total)
  • Author
    Posts
  • #1256338
    Fekry

    Hi there
    I’ve put this below filter in Snippet plugin to (Show last update date on posts and google results), but updated word shows in every post I publish, not only in the updated ones as I wish.
    May you show me what I should do ?
    Thanks
    …………………………..
    add_filter( ‘generate_post_date_output’, function( $output, $time_string ) {
    $time_string = ‘<time class=”entry-date published” datetime=”%1$s” itemprop=”datePublished”>%2$s</time>’;

    if ( get_the_time( ‘U’ ) !== get_the_modified_time( ‘U’ ) ) {
    $time_string = ‘<time class=”entry-date updated-date” datetime=”%3$s” itemprop=”dateModified”>%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”>updated: %s</span> ‘,
    $time_string
    );
    }, 10, 2 );

    #1256705
    Leo
    Staff
    Customer Support
    #1256772
    Fekry

    Hi Leo.
    that is not working? Word (last updated) shows in the post which I just published and I did not modified it.
    May you check the “URL” link please?

    #1256838
    Leo
    Staff
    Customer Support

    Can you disable the coming soon page?

    Are we referring to what is displayed or the source?

    #1256857
    Fekry

    I disabled the coming soon page. You can have a look now.

    #1256933
    Fekry

    leo, I am waiting your help and do not want to disable the coming soon page for long time, my site is not ready yet.

    #1256994
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    Can you try the updated function here?: https://docs.generatepress.com/article/generate_post_date_output/#only-show-updated-date

    Let me know 🙂

    #1257015
    Fekry

    Hi Tom.
    this filter also shows updated word in all posts (updated and just published) and remove the date.
    I’ve put a new URL link in the orginal message for a fake post I just published.
    I need word “updated” to show only in the really updated posts.
    What should I do?

    #1257022
    Tom
    Lead Developer
    Lead Developer

    That code shouldn’t actually include any “updated” or “published” words – was going to add those using CSS after.

    Can you make sure you’re not using any other filters/custom functions?

    #1257024
    Fekry

    Ok Tom. It was my fault. Now there is now “updated” word. What should do next (CSS)?

    #1257025
    Tom
    Lead Developer
    Lead Developer

    Here you go:

    .updated-date:before {
        content: "Updated on ";
    }
    
    .published:before {
        content: "Published on ";
    }
    #1257032
    Fekry

    I’ve modified the post, but nothing shows in the meta line! I need to show “updated” word.

    #1257055
    Fekry

    Hello Tom..

    #1257446
    David
    Staff
    Customer Support

    Hi there,

    can you remove the coming soon so we can take a look

    #1257694
    Fekry

    Sure. May you check it please.

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