[Resolved] Display Last Updated Date in google

Home Forums Support Display Last Updated Date in google

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #1305494
    John

    I want to display this post last updated date on google. Using this PHP snippet

    function display_modified_date_shortcode () {
        $mod_date = get_the_modified_date();
        if ( get_the_date() !== $mod_date ) {
            return 'Updated On ' . $mod_date;
        }
    }
    add_shortcode( 'modified_date', 'display_modified_date_shortcode' );

    And this shortcode in my post hero header.

    [modified_date]

    I also unchecked “post date” from single post settings from customizer.

    Last updated date showing on post.

    Is my process okay to show the modified date on google?

    Or need to do anything?

    Thanks

    #1305616
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    Since you’re using JSON-LD to provide the correct schema, simply displaying the date like that should be just fine.

    If you weren’t using JSON-LD, you would likely need to add microdata to the text itself. However, that shouldn’t be necessary in your case 🙂

    #1305688
    John

    Hi tom,

    I have re-crawled one of my older posts from google search console but still google showing the published date.

    #1306611
    Tom
    Lead Developer
    Lead Developer

    Have you run your site through a structured data testing tool?: https://search.google.com/structured-data/testing-tool/u/0/

    Can Google see the modified date?

    Whether they display it or not is up to them. Typically they will display the date that’s in the structured data AND displaying on the page. So if it’s in the structured data and the updated date is the only date on the page, they should pick it up.

    #1306657
    John

    Checked in structure data testing tool. https://prnt.sc/sq6qey

    Both published and modified dates are showing in article schema.

    If I got your point, I have to remove the published date and only keep the modified date.

    How can I do this?

    I’m using “Markup (JSON-LD) structured in schema.org” plugin to display article schema.

    #1307073
    Tom
    Lead Developer
    Lead Developer

    From what I can see, you only have the updated date visible on the page – is that correct? If so, I think that’s all it *should* take for Google to start using it.

    #1315198
    John

    Hi Tom,

    Waiting few days but Google not showing any date.

    Could you please add microdata for this text of code?

    function display_modified_date_shortcode () {
        $mod_date = get_the_modified_date();
        if ( get_the_date() !== $mod_date ) {
            return 'Updated On ' . $mod_date;
        }
    }
    add_shortcode( 'modified_date', 'display_modified_date_shortcode' );

    I think It can be helpful

    #1315884
    Tom
    Lead Developer
    Lead Developer

    Try this:

    function display_modified_date_shortcode () {
        $mod_date = get_the_modified_date();
        if ( get_the_date() !== $mod_date ) {
            return sprintf(
                'Updated On <time class="updated" datetime="%1$s" itemprop="dateModified">%2$s</time>',
                esc_attr( get_the_modified_date( 'c' ) ),
                esc_html( $mod_date )
            );
        }
    }
    add_shortcode( 'modified_date', 'display_modified_date_shortcode' );
    #1315911
    John

    Thanks tom,

    Applied but no date showing. Might be this CSS cause the issue.

    .page-hero time.updated {
        display: none;
    }

    What should I do?

    #1316049
    Leo
    Staff
    Customer Support

    Can you try removing that CSS?

    #1316371
    John

    No, I don’t know where is the CSS file. Is It in style.css?

    More so, What happen when you update the core file in future?

    #1316716
    John

    Solved my problem. Thanks, both of you!

    #1316911
    Leo
    Staff
    Customer Support
Viewing 13 posts - 1 through 13 (of 13 total)
  • You must be logged in to reply to this topic.