The effects of alcohol on sustanon 250 leucine for – real weight loss & bodybuilding benefits?
Post Rating - Using...
 
Share:
Notifications
Clear all

[Solved] Post Rating - Using Aggregate Rating Schema

1 Posts
1 Users
0 Reactions
13.5 K Views
Tom
 Tom
(@tomson)
Honorable Member Support
Joined: 9 years ago
Posts: 508
Topic starter  

Started from version 7.0.2 we've disabled the Aggregate Rating Schema for Post and Comment Rating. Before, we were using "Product" rating type as a general type for all, because the "Article" type doesn't exist, it's no longer supported by Google. Currently, Google only supports these types:

 

If you want to enable back the "Product" type, just navigate to Dashboard > wpDiscuz > Settings > Article and Comment Rating Tab and enable the "Enable Aggregate Rating Schema" option. But, if the pages you've enabled are not products, you'll get Google Search Console error reports, like this:

  • Missing field ‘brand’ (optional)
  • Missing field ‘offers’ (optional)
  • Missing field ‘sku’ (optional)
  • Missing field ‘review’ (optional)
  • Missing field ‘image’ (optional)
  • Missing field ‘description’ (optional)
  • No global identifier provided (e.g. gtin, mpn, isbn) (optional)

So, we don't recommend use it for non-product pages.

On the other hand, the Q&A of this Google Blog says: https://webmasters.googleblog.com/2019/09/making-review-rich-results-more-helpful.html says this:

  • Question: Will sites that gather reviews about other organizations be affected?
  • Answer: No, that’s unchanged. Sites that gather reviews can show up with review snippets (for their reviews of other organizations) in search results.

So you may consider to use the Aggregate Rating Schema with the "Product" type, this is your choice, and we're not responsive for the Google Console errors. Here is an example of such request: https://wpdiscuz.com/community/general-forum/update-7-0-2-aggregate-rating-schema/

 

However, if your articles are Books, Courses, Events, How-to's, Local businesses, Movies, Products, Recipes, Software App's, you can put the corresponding hook code mentioned below, into your active WordPress theme functions.php file, then enable the "Aggregate Rating Schema" option in Dashboard > wpDiscuz > Settings > Article and Comment Rating Tab.

For the Book post type use this code:

add_filter('wpdiscuz_rating_schema', function ( $rating_schema, $key, $postid ){
    $my_rating_schema = 'Book';
    $rating_schema = str_replace(__('Article Rating', 'wpdiscuz'), $my_rating_schema . ' Rating', $rating_schema);
    return preg_replace( '|schema\.org\/Product|i', 'schema.org/' . sanitize_text_field($my_rating_schema) , $rating_schema);
},11, 3);

For the Course post type use this code:

add_filter('wpdiscuz_rating_schema', function ( $rating_schema, $key, $postid ){
    $my_rating_schema = 'Course';
    $rating_schema = str_replace(__('Article Rating', 'wpdiscuz'), $my_rating_schema . ' Rating', $rating_schema);
    return preg_replace( '|schema\.org\/Product|i', 'schema.org/' . sanitize_text_field($my_rating_schema) , $rating_schema);
},11, 3);

For the Event post type use this code:

add_filter('wpdiscuz_rating_schema', function ( $rating_schema, $key, $postid ){
    $my_rating_schema = 'Event';
    $rating_schema = str_replace(__('Article Rating', 'wpdiscuz'), $my_rating_schema . ' Rating', $rating_schema);
    return preg_replace( '|schema\.org\/Product|i', 'schema.org/' . sanitize_text_field($my_rating_schema) , $rating_schema);
},11, 3);

For the How-To post type use this code:

add_filter('wpdiscuz_rating_schema', function ( $rating_schema, $key, $postid ){
    $my_rating_schema = 'HowTo';
    $rating_schema = str_replace(__('Article Rating', 'wpdiscuz'), $my_rating_schema . ' Rating', $rating_schema);
    return preg_replace( '|schema\.org\/Product|i', 'schema.org/' . sanitize_text_field($my_rating_schema) , $rating_schema);
},11, 3);

For the Local Business post type use this code:

add_filter('wpdiscuz_rating_schema', function ( $rating_schema, $key, $postid ){
    $my_rating_schema = 'LocalBusiness';
    $rating_schema = str_replace(__('Article Rating', 'wpdiscuz'), $my_rating_schema . ' Rating', $rating_schema);
    return preg_replace( '|schema\.org\/Product|i', 'schema.org/' . sanitize_text_field($my_rating_schema) , $rating_schema);
},11, 3);

For the Movie type use this code:

add_filter('wpdiscuz_rating_schema', function ( $rating_schema, $key, $postid ){
    $my_rating_schema = 'Movie';
    $rating_schema = str_replace(__('Article Rating', 'wpdiscuz'), $my_rating_schema . ' Rating', $rating_schema);
    return preg_replace( '|schema\.org\/Product|i', 'schema.org/' . sanitize_text_field($my_rating_schema) , $rating_schema);
},11, 3);

For the Recipe type use this code:

add_filter('wpdiscuz_rating_schema', function ( $rating_schema, $key, $postid ){
    $my_rating_schema = 'Recipe';
    $rating_schema = str_replace(__('Article Rating', 'wpdiscuz'), $my_rating_schema . ' Rating', $rating_schema);
    return preg_replace( '|schema\.org\/Product|i', 'schema.org/' . sanitize_text_field($my_rating_schema) , $rating_schema);
},11, 3);

For the Software Application type use this code:

add_filter('wpdiscuz_rating_schema', function ( $rating_schema, $key, $postid ){
    $my_rating_schema = 'SoftwareApplication';
    $rating_schema = str_replace(__('Article Rating', 'wpdiscuz'), $my_rating_schema . ' Rating', $rating_schema);
    return preg_replace( '|schema\.org\/Product|i', 'schema.org/' . sanitize_text_field($my_rating_schema) , $rating_schema);
},11, 3);

 

This article helps to add a custom code to your website: How to Easily Add Custom Code in WordPress (without Breaking Your Site)

 

Important Notes

The wpDiscuz rating section cannot be responsive for the whole page and turn it to a X type of page. Most of the schema properties (including the image) should come from your page schemas which should be provided by some plugins or the theme. For example if you want to create a Local Business pages, you should use plugins which creates Local Business pages with all necessary properties. In case you don't use any plugin, you still need some plugin to insert missing schema properties.

 

Again, wpDiscuz Rating is only designed to add rating properties, it compliments with the rating properties, it doesn’t convert your page to Local Business and it doesn’t cover all Local Business properties because it’s a comment plugin not a Local Business builder plugin. Even if the missing attribute is just one image you still need a dedicated solution for creating Local Business pages.


   
Share: