Site logo

Archived topic

Last Modified Date In Google Search

12 replies · Started by Stevie on September 12, 2019

Viewing posts 1–13 of 13

Hi guys
Still working on a test site here with GP. The site I'll be moving to GP has a heap of posts
going back years. The permalink structure I chose back in the day included the date.
I have two questions.

1.

On this test site I added the CSS below to show the last modified date. It shows nicely on the page itself,
but not on Google.

/* last updated */

.posted-on .updated {
display: inline-block;
}

.posted-on .updated + .entry-date {
display: none;
}

.posted-on .updated:before {
content: "Last Updated ";
}

Is there anything I'm leaving out, as Google isn't picking that up.

2.

What are your views on the efficacy of changing permalinks on an old site like mine to exclude post dates?
My main site used to rank much higher and now my main visits are to my WP pages which of course have no dates in the urls. Does Google really drop you down in search because of dates?
There is some debate about this and I know I would have to set up a redirect instruction in the htaccess.

I would probably be happier to leave well alone, as they go back nearly 10 years, but I would definitely
want to solve the 'last modified date' not showing in Google Serps.

This code works for me too.

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 = 'Updated On: <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">%s</span> ',
        $time_string
    );
}, 10, 2 );

How to add PHP https://docs.generatepress.com/article/adding-php/

Thanks for that Leo. Is that a CSS code I can add in the custom css section of customiser?

Thanks David. I'll give that plugin a go. Do I need to remove that CSS I am using?

You shouldn't require the CSS

Hi guys
I really appreciate your efforts to help me and I want to figure this out.
But the suggestion above doesn't appear to work. I applied the html markup php snippet, removed the CSS above, cleared the cache and resubmitted sitemap. Now only the original date shows again on Google search.
I ran a test post through Google rich snippets tool and it shows the following:

datePublished
2019-01-29T21:58:27+00:00
dateModified
2019-09-20T21:25:28+00:00

Is there a proven CSS to work with the html php snippet that will show only updated date in
Google search?
Thanks again for all your help

The snippet is working as the Post Meta Date is only displaying the Updated Date.
One of your plugins, most likely SEO, is outputing <meta> tags in the <head> of the site for those two dates you see.

I have Yoast SEO. Should I or can I change this, or should I just waits for Google SERP to do its thing?
At present - I am using the suggested html markup snippet, and no CSS added
Google rich snippets tool shows the following:

datePublished
2019-01-29T21:58:27+00:00
dateModified
2019-09-20T21:25:28+00:00

Google will choose to display a relevant date based upon many ( unknown ) factors.
One thing it does make clear is it will ignore dates that are not visible on the page itself.
As you're only displaying the modified date on the post it should pick that date. It may take some time for that change to show.

If you really must remove the datePublished then you would need to speak with Yoast.

Thanks David, I think I've probably done what can be done at this stage.
Many thanks !

You're welcome

This archived topic is closed to new replies.