Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author dpowney

    (@dpowney)

    Hi Oliver,

    I noticed this as well in the last few days. It seems the Google rich snippets has changed…

    As a workaround, you can edit the rating-result.php template file if you’re comfortable with PHP:

    // default itemscope is "https://schema.org/Article"
    			$microdata = '<div itemscope itemtype="' . "https://schema.org/Article" . '" style="display: none;">';
    
    			$post_obj = get_post( $post_id );
    			$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post_id ) );
    			$image_content = '';
    			$image_width = '';
    			$image_height = '';
    			if ( isset( $image[0] ) ) {
    				$image_content = $image[0];
    				$image_width = $image[1];
    				$image_height = $image[2];
    			}
    			$display_name = get_the_author_meta( 'display_name', $post_obj->post_author );
    
    			// default required itemprops for "https://schema.org/Article"
    			$microdata .= '<meta itemprop="datePublished" content="' . date( 'Y-m-d', strtotime( $post_obj->post_date ) ) . '" />';
    			$microdata .= '<meta itemprop="dateModified" content="' . date( 'Y-m-d', strtotime( $post_obj->post_modified ) ) . '" />';
    
    			$microdata .= '<meta itemprop="headline" content="' . $post_obj->post_title . '" />';
    
    			$microdata .= '<div itemprop="mainEntityOfPage"><meta itemprop="name">' . $post_obj->post_title . '</meta></div>';
    
    			$microdata .= '<div itemprop="image" itemscope itemtype="https://schema.org/ImageObject">';
    			$microdata .= '<meta itemprop="url" content="' . $image_content . '">';
    			$microdata .= '<meta itemprop="width" content="' . $image_width . '">';
    			$microdata .= '<meta itemprop="height" content="' . $image_height . '">';
    			$microdata .= '</div>';
    
    			// author
    			$microdata .= '<div itemprop="author" itemscope itemtype="https://schema.org/Person">';
    			$microdata .= '<span itemprop="name">' . $display_name. '</span>';
    			$microdata .= '</div>';
    
    			$microdata .= '<div itemprop="publisher" itemscope itemtype="https://schema.org/Organization">';
    			$microdata .= '<meta itemprop="name" content="' . get_bloginfo('name') . '">';
    			$microdata .= '<div itemprop="logo" itemscope itemtype="https://schema.org/ImageObject">';
    			$microdata .= '<meta itemprop="url" content="' . get_site_icon_url() . '">';
    			$microdata .= '</div>';
    
    			// add aggregate rating
    			$microdata .= '<span itemprop="aggregateRating" itemscope itemtype="https://schema.org/AggregateRating">'
    					. '<span itemprop="ratingValue">' . $rating_result['adjusted_star_result'] . '</span>/<span itemprop="bestRating">5</span>'
    					. '<span itemprop="ratingCount">' . $rating_result['count_entries'] . '</span>'
    					. '</span>';
    
    			$microdata .= '</div>';

    I will be updating the plugin in the new year to fix this.

    Daniel

    Thread Starter Oliver Nielsen

    (@oliver-nielsen)

    Thanks for the info Daniel.

    Thread Starter Oliver Nielsen

    (@oliver-nielsen)

    Hi Daniel
    Just info: I have edited the php file, but still get two errors.

    url: missing and is required

    Either rating count or review count must be specified.

    Thread Starter Oliver Nielsen

    (@oliver-nielsen)

    Topic is resolved, Google accept the snippet

    Thank you for this snippet.

    I had to change $rating_result[‘count_entries’] to $rating_result[‘count’] to make it work.

    And also paste a link to my logo instead of get_site_icon_url() because i did not set this option.

    Will you make an update with this?

    Another

    $microdata .= ‘</div>’;

    is required before

    // add aggregate rating

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Google structured tools errors in the Article snippet’ is closed to new replies.