Site logo

Archived topic

Display Last Updated Date in google

12 replies · Started by John on May 28, 2020

Viewing posts 1–13 of 13

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

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 :)

Hi tom,

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

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.

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.

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.

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

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' );

Thanks tom,

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

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

What should I do?

Can you try removing that CSS?

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?

Solved my problem. Thanks, both of you!

No problem :)

This archived topic is closed to new replies.