Title: Bug in schema code
Last modified: September 24, 2019

---

# Bug in schema code

 *  Resolved [Milan.Nikolic](https://wordpress.org/support/users/milannikolic/)
 * (@milannikolic)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/bug-in-schema-code/)
 * Hi, I would like to report a bug for your plugin on schema.org structured data.
   Aggregate Rating show an error with the newest Google schema update.
 * So everybody who uses show_rich_snippets=true will experience this.
 * Hopefully you can fix this soon,
    Best, Milan

Viewing 7 replies - 1 through 7 (of 7 total)

 *  [Bastbra](https://wordpress.org/support/users/comicschau/)
 * (@comicschau)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/bug-in-schema-code/#post-11970630)
 * Please fix this! As Milan said Google doesn’t show anything (ratings).
 *  Plugin Author [dpowney](https://wordpress.org/support/users/dpowney/)
 * (@dpowney)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/bug-in-schema-code/#post-11978817)
 * Hi [@milannikolic](https://wordpress.org/support/users/milannikolic/) [@comicschau](https://wordpress.org/support/users/comicschau/),
 * Thanks for reporting this bug. Some recent Google changes has broken the review
   and aggregate rating microdata in the free and premium versions of the Multi 
   Rating plugin. A specific item type is now required for reviews whereas previously
   a generic [http://schema.org/Thing](http://schema.org/Thing) item was used. See
   here [https://webmasters.googleblog.com/2019/09/making-review-rich-results-more-helpful.html](https://webmasters.googleblog.com/2019/09/making-review-rich-results-more-helpful.html)
 * There is a quick fix for the following items:
    – [http://schema.org/Product](http://schema.org/Product)–
   [http://schema.org/Organization](http://schema.org/Organization) – [http://schema.org/MusicRecording](http://schema.org/MusicRecording)–
   [http://schema.org/MusicPlaylist](http://schema.org/MusicPlaylist) – [http://schema.org/MediaObject](http://schema.org/MediaObject)–
   [http://schema.org/Game](http://schema.org/Game) – [http://schema.org/Episode](http://schema.org/Episode)–
   [http://schema.org/CreativeWorkSeries](http://schema.org/CreativeWorkSeries) –
   [http://schema.org/CreativeWorkSeason](http://schema.org/CreativeWorkSeason)
 * Add the following code to your theme functions.php file and replace [http://schema.org/Product](http://schema.org/Product)
   with your item type.
 *     ```
       function my_microdata_fix( $microdata, $post_id ) {
       	$microdata = '<span itemprop="itemReviewed" itemscope itemtype="http://schema.org/Product">'
       			. '<meta itemprop="name" content="' . get_the_title( $post_id ) . '" />'
       			. '</span>';
       	return $microdata;
       }
       add_filter( 'mr_microdata_aggregate_rating_item_reviewed', 'my_microdata_fix', 10, 2 );
       ```
   
 * For the premium version, the only difference is the prefix of the filter name(
   mrp_ instead of mr_).
 * For [http://schema.org/Recipe](http://schema.org/Recipe) and [http://schema.org/LocalBusiness](http://schema.org/LocalBusiness)
   items, an image property is also required. We can add the post thumbnail image
   for example:
 *     ```
       function my_microdata_fix( $microdata, $post_id ) {
       	$microdata = '<span itemprop="itemReviewed" itemscope itemtype="http://schema.org/Recipe">'
       			. '<meta itemprop="name" content="' . get_the_title( $post_id ) . '" />'
       		    . '<meta itemprop="image" content="' . get_the_post_thumbnail_url( $post_id ) . '" />'
       			. '</span>';
       	return $microdata;
       }
       add_filter( 'mr_microdata_aggregate_rating_item_reviewed', 'my_microdata_fix', 10, 2 );
       ```
   
 * The following item types require many properties specific to the type of item.
   So there is no quick fix for these items unfortunately.
    – [http://schema.org/SoftwareApplication](http://schema.org/SoftwareApplication)–
   [http://schema.org/Movie](http://schema.org/Movie) – [http://schema.org/HowTo](http://schema.org/HowTo)–
   [http://schema.org/Event](http://schema.org/Event) – [http://schema.org/Course](http://schema.org/Course)–
   [http://schema.org/Book](http://schema.org/Book)
    -  This reply was modified 6 years, 8 months ago by [dpowney](https://wordpress.org/support/users/dpowney/).
 *  Plugin Author [dpowney](https://wordpress.org/support/users/dpowney/)
 * (@dpowney)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/bug-in-schema-code/#post-11978827)
 * Hi [@milannikolic](https://wordpress.org/support/users/milannikolic/) [@comicschau](https://wordpress.org/support/users/comicschau/),
 * Thanks for reporting this bug. Some recent Google changes has broken the review
   and aggregate rating microdata in the free and premium versions of the Multi 
   Rating plugin. A specific item type is now required for reviews whereas previously
   a generic [http://schema.org/Thing](http://schema.org/Thing) item was used. See
   here [https://webmasters.googleblog.com/2019/09/making-review-rich-results-more-helpful.html](https://webmasters.googleblog.com/2019/09/making-review-rich-results-more-helpful.html)
 * There is a quick fix for the following items:
    – [http://schema.org/Product](http://schema.org/Product)–
   [http://schema.org/Organization](http://schema.org/Organization) – [http://schema.org/MusicRecording](http://schema.org/MusicRecording)–
   [http://schema.org/MusicPlaylist](http://schema.org/MusicPlaylist) – [http://schema.org/MediaObject](http://schema.org/MediaObject)–
   [http://schema.org/Game](http://schema.org/Game) – [http://schema.org/Episode](http://schema.org/Episode)–
   [http://schema.org/CreativeWorkSeries](http://schema.org/CreativeWorkSeries) –
   [http://schema.org/CreativeWorkSeason](http://schema.org/CreativeWorkSeason)
 * Add the following code to your theme functions.php file and replace [http://schema.org/Product](http://schema.org/Product)
   with your item type.
 *     ```
       function my_microdata_fix( $microdata, $post_id ) {
       	$microdata = '<span itemprop="itemReviewed" itemscope itemtype="http://schema.org/Product">'
       			. '<meta itemprop="name" content="' . get_the_title( $post_id ) . '" />'
       			. '</span>';
       	return $microdata;
       }
       add_filter( 'mr_microdata_aggregate_rating_item_reviewed', 'my_microdata_fix', 10, 2 );
       ```
   
 * For the premium version, the only difference is the prefix of the filter name(
   mrp_ instead of mr_).
 * For [http://schema.org/Recipe](http://schema.org/Recipe) and [http://schema.org/LocalBusiness](http://schema.org/LocalBusiness)
   items, an image property is also required. We can add the post thumbnail image
   for example:
 *     ```
       function my_microdata_fix( $microdata, $post_id ) {
       	$microdata = '<span itemprop="itemReviewed" itemscope itemtype="http://schema.org/Recipe">'
       			. '<meta itemprop="name" content="' . get_the_title( $post_id ) . '" />'
       		    . '<meta itemprop="image" content="' . get_the_post_thumbnail_url( $post_id ) . '" />'
       			. '</span>';
       	return $microdata;
       }
       add_filter( 'mr_microdata_aggregate_rating_item_reviewed', 'my_microdata_fix', 10, 2 );
       ```
   
 * The following item types require many properties specific to the type of item.
   So there is no quick fix for these items unfortunately.
    – [http://schema.org/SoftwareApplication](http://schema.org/SoftwareApplication)–
   [http://schema.org/Movie](http://schema.org/Movie) – [http://schema.org/HowTo](http://schema.org/HowTo)–
   [http://schema.org/Event](http://schema.org/Event) – [http://schema.org/Course](http://schema.org/Course)–
   [http://schema.org/Book](http://schema.org/Book)
 *  [Oliver Nielsen](https://wordpress.org/support/users/oliver-nielsen/)
 * (@oliver-nielsen)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/bug-in-schema-code/#post-12147564)
 * H
    -  This reply was modified 6 years, 6 months ago by [Oliver Nielsen](https://wordpress.org/support/users/oliver-nielsen/).
    -  This reply was modified 6 years, 6 months ago by [Oliver Nielsen](https://wordpress.org/support/users/oliver-nielsen/).
    -  This reply was modified 6 years, 6 months ago by [Oliver Nielsen](https://wordpress.org/support/users/oliver-nielsen/).
    -  This reply was modified 6 years, 6 months ago by [Oliver Nielsen](https://wordpress.org/support/users/oliver-nielsen/).
 *  Thread Starter [Milan.Nikolic](https://wordpress.org/support/users/milannikolic/)
 * (@milannikolic)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/bug-in-schema-code/#post-12149399)
 * It looks like this is now resolved in plugin. Review property now works without
   any errors.
 * Thanks
 *  Plugin Author [dpowney](https://wordpress.org/support/users/dpowney/)
 * (@dpowney)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/bug-in-schema-code/#post-12149623)
 * For the technical people, you might like to check out this code snippet to enable
   JSON-LD rich snippets. I will be looking at replacing the schema.org microdata
   with JSON-LD in the future.
 *     ```
       /**
        * Adds JSON-LD ratings for schema.org item types
        */
       function mrp_jsonld_ratings() {
   
       	if ( is_page() || is_single() ) {
   
           	$post_id = get_queried_object_id();
           	if ($post_id == null) {
           		return;
           	}
   
           	// in case you only want to add rich snippets on posts which have auto placement enabled...
           	if ( ! apply_filters( 'mrp_can_apply_auto_placement', true, 'the_title', null, $post_id ) ) {
       			return;
       		}
   
           	$post_type = get_post_type( $post_id );
           	$rating_form_id = MRP_Utils::get_rating_form( $post_id );
   
           	$rating_result = MRP_Multi_Rating_API::get_rating_result( array(
       			'post_id' => $post_id,
       			'rating_form_id' => $rating_form_id
       		) );
       		if ($rating_result == null 
       			|| ($rating_result !== null && $rating_result['count_entries'] === 0)) {
       			return;
       		}
   
           	$item_type_map = [
           		"post" => 'Product',
           		"page" => 'Product'
           	];
           	$item_type = $item_type_map[$post_type];
           	$post_title = get_the_title( $post_id );
           	$post_thumbnail_url = get_the_post_thumbnail_url( $post_id );
           	$post_excerpt = get_the_excerpt( $post_id );
   
       		?>
       		<script type="application/ld+json">
       		{
       		    "@context": "https://schema.org/",
       		    "@type": "<?php echo $item_type; ?>",
       		    "name": "<?php echo $post_title; ?>",
       		    <?php if ($post_thumbnail_url) { ?>
       		    "image": [
       		   	    "<?php echo $post_thumbnail_url; ?>"
       		    ],
       		    <?php } if ($post_excerpt) { ?>
       			"description": "<?php echo esc_html($post_excerpt); ?>",
       		    <?php } ?>
       			"aggregateRating": {
       		        "@type": "AggregateRating",
       		        "ratingValue": "<?php echo $rating_result['adjusted_star_result']; ?>",
       		        "reviewCount": "<?php echo $rating_result['count_entries']; ?>"
       		    }
       		}
       		</script>
       		<?php
       	}
       }
       add_action( 'wp_head', 'mrp_jsonld_ratings' );
       ```
   
 *  [Oliver Nielsen](https://wordpress.org/support/users/oliver-nielsen/)
 * (@oliver-nielsen)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/bug-in-schema-code/#post-12165682)
 * Hi
    No the problem is not resolved !
 * All my snippets works 100 % except the aggregate rating.
 * Regards
    Oliver

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Bug in schema code’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/multi-rating_d6dfe6.svg)
 * [Multi Rating](https://wordpress.org/plugins/multi-rating/)
 * [Support Threads](https://wordpress.org/support/plugin/multi-rating/)
 * [Active Topics](https://wordpress.org/support/plugin/multi-rating/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/multi-rating/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/multi-rating/reviews/)

 * 6 replies
 * 3 participants
 * Last reply from: [Oliver Nielsen](https://wordpress.org/support/users/oliver-nielsen/)
 * Last activity: [6 years, 6 months ago](https://wordpress.org/support/topic/bug-in-schema-code/#post-12165682)
 * Status: resolved