1

I tried using the AggregateRating and used the code below. The values of $aggregate_rating and $total_reviews is not empty, and tried printing its value.

Now I added the code inside my WordPress post, and checked the preview on Google's rich snippet testing tool. AggregateRating is not showing.

<div itemscope="" itemtype="http://schema.org/AutoRepair">
    <strong><span itemprop="name">GMD Auto Shop</span></strong>
    [php]
        echo "<div itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">
        <span itemprop="ratingValue">". $aggregate_rating . " </span> stars for <span itemprop="reviewCount">" . 
        $total_reviews . "</span></div>reviews.";
    [/php]        
    <span itemprop="streetAddress">Kamagong Street, Lahug</span>
    <div itemprop="address" itemscope="" itemtype="http://schema.org/PostalAddress"><span itemprop="addressLocality">Cebu City</span>,
        <span itemprop="addressRegion"> Cebu</span>
        <span itemprop="postalCode">6000</span>
    </div>
    Phone: <span itemprop="telephone">032-417-4700</span>
    <div itemprop="geo" itemscope="" itemtype="http://schema.org/GeoCoordinates">Latitude: 40 deg 44 min 54.36 sec N
        Longitude: 123° 54.037'
        <meta itemprop="latitude" content="40.75" />
        <meta itemprop="longitude" content="54.98" />
    </div>
</div>
4
  • Although http://schema.org/AutoRepair is a valid itemtype, in my experience any itemtype other than http://schema.org/Product does not show in the rich snippet testing tool. I find this frustrating as it means listing organisations as products. Although the above will get your rating shown in the snippets tool, I am interested to know if there is a solution that allows us to use the correct itemtype and see a rating in the rich snippets tool. Dec 12, 2013 at 18:02
  • Your PHP code looks invalid. [php] should be <?php>. Also, you are using a double quoted string with double quotes inside it. There is no way that what you pasted in would print out valid markup that Google's tool could understand. Dec 13, 2013 at 11:59
  • 2
    I am using a plugin in wordpress that enables the php code inserted inside a post. [php] is like a short code.
    – rahstame
    Dec 15, 2013 at 6:03
  • You should show us the actual HTML (only this can be checked in Google’s Testing Tool), after PHP was executed.
    – unor
    Jun 30, 2015 at 9:08

1 Answer 1

1

@lordzden your PHP as Stephen points out is invalid. Your echo should look like

<?php
$aggregate_rating = '6.5';
$total_reviews = '24';

echo '<div itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating"><span itemprop="ratingValue">'. $aggregate_rating .'</span> stars for <span itemprop="reviewCount">'. $total_reviews . '</span></div>reviews';
?>
2
  • He/she is using shortcode... in WordPress Jan 3, 2014 at 11:23
  • @bybe I know that they are using a shortcode plugin. They seem to be a little familiar with PHP enough to know that my open and close tags would need to be replaced with their shortcode.
    – Anagio
    Jan 3, 2014 at 20:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.