Site logo

Archived topic

How to remove post date from google snippet

27 replies · Started by Mohit on September 21, 2018

Viewing posts 16–28 of 28

Can you show me a post where the date has disappeared?

Add this CSS:

.page-hero time.updated {
    display: inline-block;
}

Hey Tom,

Thanks it's working

You're welcome :)

Hi Tom,

On applying the code that you shared I found that the date from the google snippet removed for updated posts. How can I show updated date in google search?

I'm not sure I understand. What code removed the updated date?

add_filter( 'generate_page_hero_post_date', function() {
    $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="updated" 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 $time_string;
} );

this code OR:

.page-hero time.updated {
    display: inline-block;
}

I am not sure which one but either of these

Neither of those will remove the updated date.

The first snippet will show the updated date if it exists. If not, it will show the published date.

The second snippet simply shows the updated date HTML if necessary.

Here's what I'm seeing on the post you linked to above: https://www.screencast.com/t/mOK8iCHeL

Hey Tom,

Look at the screenshots I took after updating the posts and neither of them shows the updated date in google snippet:

https://prnt.sc/l0cea4
http://prntscr.com/l0cer5 and others

However, the posts I haven't updated shows the date in Google snippet:

http://prntscr.com/l0cf5j and all other posts.

What could be the reason for this? And how can I fix this?

Thanks

Hi Tom,

Yeah, I know nothing is instant with google but the screenshot I have sent (https://prnt.sc/l0cea4, http://prntscr.com/l0cer5) are for the posts that have been recrawled by Google after applying the code of the last update that you shared. And on recrawling the date disappeared on google snippet which was displaying before applying the code. I want to display the last updated date on google snippet just like this website:
Google Snippet: https://prnt.sc/l0qyqt
Actual Post: http://prntscr.com/l0qzj7

As you can see from the above screenshots the google snippet date is Sept 5, 2018, however, the actual post date is July 30, 2017.

Thanks

This archived topic is closed to new replies.