• 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)
  • Hi there,

    the Theme and that code simply displays the date on the page.
    it does not and cannot tell google to display that date in the SERPs. That is 100% up to google

    And you should note that your site us running RankMath Pro and it is outputting JSON-LD Schema on your site that includes dates:

    https://www.screencast.com/t/59HiMfO6XSrr

    As google prefers using JSON-LD for SERP meta, then you may want to check with RanKMath.

    Thread Starter fakhrurpedia

    (@fakhrur)

    ah, thank you david for your answer, btw that mean is fine on my site and nothing to do?

    I can’t see any issues on your site.
    The Date the theme is displaying is the same as the updatedDate in the JSON schema, so that is correct.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Last Update Not Showing On Google Serp’ is closed to new replies.