- This topic has 7 replies, 4 voices, and was last updated 2 years, 1 month ago by Fernando.
-
AuthorPosts
-
June 3, 2020 at 2:45 am #1312189Xin Yi
Hi guys,
Been on generatepress for a few years now. Great theme and support! It’s my first posting on the support forum because I do need some help with this specific issue.
My main concern is that the last updated date not updating in google searches. It’s important to me.
A bulk of my posts are supposed to reflect the latest information in the year 2020. But it’s still showing the published date (which is 2019). This is even after major updates with the content (eliminating 50%, total restructure, etc). And it has been months but it still isn’t updated. Which seems a little odd.
Observations
– I used codes gathered from generatepress
– the last updated date on SERPs hasn’t change once even after constant updates. Only published date is shown
– on the article page, it shows exactly how I want it to be (visually), but the “last updated” words doesn’t seem to be regular text (not sure whether it’s an issue).I understand that this might not be under the scope but I’ve no clue how to rectify this, so would greatly appreciate if someone can check out whether the codes are alright. Thanks!
June 3, 2020 at 9:37 am #1312898TomLead DeveloperLead DeveloperHi there,
This is something we’ll be addressing directly in the theme. While they don’t directly say it, it seems Google will only show the updated date if the updated date is the only date in the HTML source of the page.
For now, try this function: https://docs.generatepress.com/article/generate_post_date_output/#only-show-updated-date
June 3, 2020 at 11:51 am #1313076Xin YiThanks, Tom!
It seems to be working. At least the old date is taken out from the SERPs.
How do I add the text: “Update” before the date though?
Current CSS I’m using:
.entry-header, .entry-meta { text-align: center; } .byline img { width: 25px; height: 25px; border-radius: 50%; position: relative; vertical-align: middle; margin: 0 10px 0 0; } .comments-link, .posted-on { border-left: 1px solid #ddd; padding-left: 10px; margin-left: 10px; }
Current Function:
add_filter( 'generate_post_author_output', function() { return sprintf( ' <span class="byline">%1$s</span>', sprintf( '<span class="author vcard" itemtype="http://schema.org/Person" itemscope="itemscope" itemprop="author">%2$s<span class="author-name" itemprop="name">%1$s</span></span>', esc_html( get_the_author() ), get_avatar( get_the_author_meta( 'ID' ) ) ) ); } ); add_filter( 'generate_header_entry_meta_items', function() { return array( 'author', 'comments-link', 'date', ); } ); add_filter( 'generate_footer_entry_meta_items', function( $items ) { return array( 'categories', ); } ); // remove publisheddate 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>'; $updated_time = get_the_modified_time( 'U' ); $published_time = get_the_time( 'U' ) + 86400; if ( $updated_time > $published_time ) { $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">%s</span> ', $time_string ); }, 10, 2 );
June 3, 2020 at 4:12 pm #1313316TomLead DeveloperLead DeveloperHi there,
You can replace this line:
$time_string = '<time class="entry-date updated-date" datetime="%3$s" itemprop="dateModified">%4$s</time>';
With this:
$time_string = 'Updated: <time class="entry-date updated-date" datetime="%3$s" itemprop="dateModified">%4$s</time>';
June 3, 2020 at 8:53 pm #1313476Xin YiThanks Tom!
June 4, 2020 at 9:57 am #1314513TomLead DeveloperLead DeveloperYou’re welcome ๐
March 25, 2022 at 12:19 am #2166732QamarI Have the same issue. My all posts Show Modifed dates in SERPS.
But For the Homepage it Still shows the old Date That is 23-Mar-2020 Which is the Article Published Date.
I have many changes in post after that But I don’t Know Why still IT shows the Old date.
Here is the Screenshot.
Here is my site.
https://bestwatersoftenerblog.com/March 25, 2022 at 12:50 am #2166753Fernando Customer SupportHi Qamar,
To confirm, have you tried the step here?: https://docs.generatepress.com/article/generate_post_date_output/#only-show-updated-date
Adding PHP: https://docs.generatepress.com/article/adding-php/#code-snippets
Adding it through Code Snippets should work.
If you’ve added this, it may also be that Google hasn’t re-crawled your page just yet.
Kindly let us know. ๐
-
AuthorPosts
- You must be logged in to reply to this topic.