Last Update Not Showing On Google Serp
-
Hi, All my article not showing Last Update on google serp see this screenshoot
btw i am using this code on my gp child theme.
add_filter( 'generate_post_date_output', db_modified_time_stamp, 20, 2); function db_modified_time_stamp( $output, $time_string ) { $time_string = '<time class="entry-date published" datetime="%1$s" itemprop="datePublished">Dipublish Pada : %2$s</time> '; if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) { $time_string = '<time class="updated" datetime="%3$s" itemprop="dateModified">Diperbarui Pada : %4$s</time> ' . $time_string; } // get modified time and published time. Compare the two, If modified date exists then ouput both time strings with modified date $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" style="display:inline;">Diperbarui Pada : %4$s</time>'; } $time_string = sprintf( $time_string, esc_attr( get_the_date( 'c' ) ), esc_html( get_the_date('F j Y') ), esc_attr( get_the_modified_date( 'c' ) ), esc_html( get_the_modified_date('F j Y') ) ); $post_date = new DateTime(get_the_date( 'Y-m-d' )); $modified_date = new DateTime(get_the_modified_date( 'Y-m-d' )); $current_date = new DateTime(date('Y-m-d')); $published_date_interval = $post_date->diff($current_date); $modified_date_interval = $modified_date->diff($current_date); if ($published_date_interval->y < 2 || $modified_date_interval->y < 2 ){ return sprintf( '<span class="posted-on">%1$s </span>', // WPCS: XSS ok, sanitization ok. sprintf( '%1$s', $time_string ) ); } if ($published_date_interval->y >= 2 || $modified_date_interval->y >= 2 ) { return; } }
The page I need help with: [log in to see the link]
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Last Update Not Showing On Google Serp’ is closed to new replies.