Osclass forums

Support forums => Tips, tricks, and tutorials => Topic started by: keslar on October 10, 2017, 08:13:34 pm

Title: How to add structured data / schema / star rating to an OSclass powered website
Post by: keslar on October 10, 2017, 08:13:34 pm
I won't go into the details of the benefits of structured data / schema markup. If you want to succeed in SEO then you need all the help you can get / ranking factors in your favor, structured data being one.
This tutorial is tested and confirmed using Google's Structured Data testing tool and is what I use on my website 360occasions (http://360occasions.com)

First, you need to install the OSclass rating plugin at https://market.osclass.org/plugins/reviews-ratings/rating_35
after that, from your File manager in cpanel, navigate to oc-content/plugins/voting/
Edit view_votes.php and add the following code at the bottom then save

Code: [Select]
<script type="application/ld+json">
{ "@context": "http://schema.org",
  "@type": "Service",
  "name": "<?php echo osc_item_title(); ?>",
  "areaServed": "<?php echo osc_item_city().", ".osc_item_country(); ?>",
  "provider": "<?php echo osc_item_contact_name(); ?>",
  "description": "<?php echo osc_item_description();?>"
  <?php if ($vote['total']>1) {?>,
  "aggregateRating":
    {"@type": "AggregateRating",
    "bestRating": "5",
    "worstRating": "1",
     "ratingValue": "<?php echo $vote['vote'];?>",
     "reviewCount": "<?php echo $vote['total'];?>"
    }
    <?php ?>
}
</script>
Title: Re: How to add structured data / schema / star rating to an OSclass powered website
Post by: omid_firoznia on March 31, 2019, 02:57:43 pm
Thanks, Thats work.
But in "Product" it does not work !
is there any way to make it work in "product" too?

{there is 7 warning in "product" one of theme is about aggregateRating and it say:

The aggregateRating field is recommended. Please provide a value if available.