Rich Snippet Code Examples

Between the purchase date of the plugin and today pretty much time has passed? No problem. Here you can see the actual code snippets that can be installed as examples in the Rich Snippet WordPress Plugin. PLUS: You can find new ones as well! ;)

Address

<span itemprop="address" itemscope="" itemtype="http://schema.org/PostalAddress">
  <span itemprop="streetAddress">[streetaddress]</span>,
  <span itemprop="addressLocality">[locality]</span>,
  <span itemprop="addressRegion">[region]</span>
  <span itemprop="postalCode">[postalcode]</span>
  <span itemprop="addressCountry">[countryname]</span>
</span>

Please note: In order to use the address-snippet you need another snippet which surrounds the code. But it is also possible to expand the above snippet like this:

<div itemscope="" itemtype="http://schema.org/Organization">
  <h5 itemprop="name">[name]</h5>
  Tel:<span itemprop="telephone">( 33 1) 42 68 53 00 </span>

  [description]
  <div itemprop="address" itemscope="" itemtype="http://schema.org/PostalAddress"><span itemprop="streetAddress">[streetaddress]</span>,
    <span itemprop="addressLocality">[locality]</span>,
    <span itemprop="addressRegion">[region]</span>
    <span itemprop="postalCode">[postalcode]</span>
    <span itemprop="addressCountry">[countryname]</span>
  </div>
</div>

Please also note that Google currently does not show address information on search results.

Event

<div class="rswp-event" itemscope itemtype="http://schema.org/Event">
	<a href="<?php echo $url; ?>" itemprop="url"><h5 itemprop="name"><?php echo $name; ?></h5></a>

	<p itemprop="description"><?php echo do_shortcode( $content ); ?></p>

	<h6>Location</h6>

	<div itemprop="location" itemscope itemtype="http://schema.org/Place">
		<span itemprop="name">[organization]</span><br/>

		<div itemprop="address" itemscope itemtype="http://schema.org/PostalAddress">
			<?php
			if ( ! empty( $street ) ) {
				echo '<span itemprop="streetAddress">' . $street . '</span><br />';
			}
			if ( ! empty( $zip ) ) {
				echo '<span itemprop="postalCode">' . $zip . '</span> ';
			}
			if ( ! empty( $locality ) ) {
				echo '<span itemprop="addressLocality">' . $locality . '</span><br />';
			}
			if ( ! empty( $country ) ) {
				echo '<span itemprop="addressCountry">' . $country . '</span><br />';
			}
			?>
		</div>
		<span itemprop="geo" itemscope itemtype="http://schema.org/GeoCoordinates">
                  <meta itemprop="latitude" content="[latitude]"/>
                  <meta itemprop="longitude" content="[latitude]"/>
             </span>
	</div>

	<h6>Date and Time</h6>
	Start Date:
	<time itemprop="startDate"
		  datetime="<?php echo date( 'c', strtotime( $start_date ) ); ?>"><?php echo $start_date; ?></time>
	<?php
	if ( ! empty( $end_date ) ) {
		echo '<br /> End Date: <time itemprop="endDate" datetime="' . date( 'c', strtotime( $end_date ) ) . '">' . $end_date . '</time>';
	}
	?>
	<meta itemprop="eventStatus" content="http://schema.org/EventScheduled">
	<meta itemprop="image" content="<?php echo $image; ?>"/>
	<span itemprop="offers" itemscope itemtype="http://schema.org/Offer">
	<meta itemprop="price" content="[price]"/>
	<meta itemprop="priceCurrency" content="EUR"/>
	<meta itemprop="availability" content="http://schema.org/InStock"/>
	<meta itemprop="availabilityStarts" content="<?php echo date( 'c', strtotime( $availabilitystarts ) ); ?>"/>
	<meta itemprop="url" content="[url]"/>
		<span itemprop="inventoryLevel" itemscope itemtype="http://schema.org/QuantitativeValue">
				<meta itemprop="value" content="1000"/>
		</span>

	</span>
</div>

 

Music Group

<div itemscope="" itemtype="http://schema.org/MusicGroup">
  <h1 itemprop="name">[actor]</h1>
  Album: <span itemprop="album">[albumname]</span>
  <div itemprop="tracks"></div>
</div>

Music Recording

<div itemscope="" itemtype="http://schema.org/MusicRecording">
  <span itemprop="name">[name]</span>

  Length:<meta itemprop="duration" content="PT[minutes]M[seconds]S" />[minutes]:[seconds] - [userplays] plays

  <meta itemprop="interactionCount" content="UserPlays:[userplays]" />
  <a itemprop="url" href="[url]">Read more</a> -
  <a itemprop="audio" href="[playurl]">Play</a> -
  <a itemprop="offers" href="[buyurl]">Buy</a>

  From album: <a itemprop="inAlbum" href="[albumurl]">[albumname]</a>
</div>

People

<div itemscope itemtype="http://schema.org/Person">
  <p>My name is <span itemprop="name">[name]</span></p>

  <p>Here you can find my website:
    <a href="[url]" itemprop="url">[url]</a>.
  </p>

  <p>I live in <?php echo do_shortcode( $content ); ?></p>

  <p>And this is a picture of me:<br />
    <img src="[photo]" alt="[name]" itemprop="image" />
  </p>

  <p>I work as a <span itemprop="jobTitle">[title]</span>
  at
  <span itemprop="affiliation" itemscope itemtype="http://schema.org/Organization">
    <span itemprop="name">[affiliation]</span>
  </span>
</div>

Usage Code for posts/pages/custom post types:

[people name="WPBuddy" photo="http://wp-buddy-web.local/dev/themes/schema-corporate/wp-content/uploads/2013/01/wpbuddy-icon.png" title="Dipl. Ing. (FH)" url="http://wp-buddy-web.local" affiliation="WP-Buddy Engineer"][/people]

Also see: the live example with Google’s Rich Snippet Testing Tool

Product

<span itemscope itemtype="http://schema.org/Product">
  Product name: <span itemprop="name">[name]</span><br />
  Product image: <img itemprop="image" src="[image]" alt="[name]" /><br />
  Brand: <span itemprop="brand" itemscope itemtype="http://schema.org/Brand">
    <span itemprop="name">[brand]</span>
  </span><br />
  Identifier: <span itemprop="productID">[identifier]</span><br />
  Description: <span itemprop="description">[description]</span><br />
  <span itemprop="offers" itemscope itemtype="http://schema.org/Offer">
    Price: <span itemprop="price">[price]</span> <span itemprop="priceCurrency">USD</span>
    - <link itemprop="availability" href="http://schema.org/InStock" />In stock
  </span><br />
  <?php echo do_shortcode( $content ); ?>
</span>

Rating

<div itemscope itemtype="http://schema.org/CreativeWork">
  <span itemprop="name">[itemreviewed]</span><br />
  <p>Reviewed by <span itemprop="author" itemscope itemtype="http://schema.org/Person"><span itemprop="name">[reviewer]</span></span> on
  <time itemprop="datePublished" datetime="<?php echo date( 'c', strtotime( $dtreviewed ) ); ?>">[dtreviewed]</time>.</p>

  <p><span itemprop="description">[content]</span></p>

  <p itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">Rating:
    <span itemprop="ratingValue">[rating]</span> out of [best]
    <meta itemprop="bestRating" content="[best]" />
    <meta itemprop="worstRating" content="[worst]" />
    <meta itemprop="ratingCount" content="1" />
  </p>
</div>

Recipe

<div itemscope itemtype="http://schema.org/Recipe">
  Product name: <span itemprop="name">[name]</span><br />
  By: <span itemprop="author">[author]</span><br />
  Description: <span itemprop="description">[summary]</span><br />
  Type: <span itemprop="recipeCategory">[recipetype]</span><br />
  Image: <br /><img itemprop="image" src="[photo]" alt="[name]" /><br />
  <meta itemprop="thumbnailUrl" content="[photo]" />
  Published: <time itemprop="datePublished" datetime="<?php echo date( 'c', strtotime( $published ) ); ?>">[published]</time><br />

  Time to prepare the recipe: <meta itemprop="prepTime" content="PT[preptime]M" />[preptime] minutes <br />
  Time to cook: <meta itemprop="cookTime" content="PT[cooktime]M" />[cooktime] minutes<br />
  Duration: <meta itemprop="totalTime" content="PT[totaltime]M" />[totaltime] minutes<br />

  Nutrition: <span itemprop="nutrition" itemscope itemtype="http://schema.org/NutritionInformation">
    <span itemprop="calories">[nutrition]</span>
  </span><br />

  Servings: <span itemprop="recipeYield">[yield]</span><br />

  Ingredients:
  <?php
  foreach( explode( ',', $ingredients ) as $ingredient ){
    echo '<span itemprop="ingredients">'. $ingredient .'</span>, ';
  }
  ?>
  <br />

  Instructions: <div itemprop="recipeInstructions"><?php echo do_shortcode( $content ); ?></div><br />

  <span itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">
    <span itemprop="ratingValue">[rating]</span> stars <br />
    <span itemprop="ratingCount">[count]</span> reviews
  </span>

</div>

Restaurant with Rating

Please also add the following attributes to the list of attributes (since 2017 Google needs an “image” attribute as well):

Add this attributes
<div itemscope itemtype="http://schema.org/Restaurant">
  <span itemprop="name">[name]</span>
  <meta itemprop="image" content="[image]" />

  <div itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">
    <span itemprop="ratingValue">[ratingvalue]</span> stars
    <meta itemprop="reviewCount" content="1" />
    <meta itemprop="bestRating" content="10" />
    <meta itemprop="worstRating" content="0" />
  </div>

  <div itemprop="address" itemscope itemtype="http://schema.org/PostalAddress">
    <span itemprop="streetAddress">[streetaddress]</span>
    <span itemprop="addressLocality">[addresslocality]</span>,
    <span itemprop="addressRegion">[addressregion]</span> <span itemprop="postalCode">[postalcode]</span>
  </div>
  <p>Phone: <span itemprop="telephone">[telephone]</span><br />
  URL: <a itemprop="url" href="[url]">[url]</a></p>

  <p>Opening Hours:<br />
    <meta itemprop="openingHours" content="[openinghours1]" />[openinghours1]<br />
    <meta itemprop="openingHours" content="[openinghours2]" />[openinghours2]</p>

    <p>Categories:<br />
    <?php
    foreach( explode( ',', $categories ) as $category ){
      echo '<span itemprop="servesCuisine">'. $category .'</span>, ';
    }
    ?>
  </p>

  <p>Price Range: <span itemprop="priceRange">[pricerange]</span></p>
</div>

You can then use the shortcode like this:

[restaurant name="Hofbräuhaus München" ratingvalue="10" streetaddress="Platzl 9" addresslocality="Muenchen" addressregion="BY" postalcode="80331" telephone="+49 (0) 89 / 29 01 36-1 00" url="http://www.hofbraeuhaus.de" openinghours1="Mo-Su 09:00-23:30" openinghours2="" categories="Bavarian,German" pricerange="$$"][/restaurant]

Photograph

<div itemscope itemtype="http://schema.org/Photograph">
  <a href="[url]" itemprop="url"><img itemprop="image" src="[image_url]" /></a>
  <meta itemprop="name" value="[image_name]" />
  <p>Photographer:
    <span itemprop="accountablePerson" itemscope itemtype="http://schema.org/Person">
      <span itemprop="name">[photographer_name]</span>
      <span itemprop="url">[photographer_url]</span>
    </span>
  </p>
  <div itemprop="description"><p>[content]</p></div>
</div>

Review (on a product)

Please note that reviews can only be attached to either a CreativeWork, an Offer, an Organization, a Place, or a Product. This example shows a review for a product.

Please add the following attributes for your new Review shortcode:

Product Review Rich Snippet Attributes
<div itemscope itemtype="http://schema.org/Product">
	<span itemprop="name">[product_name]</span>
	<br /><img src="[img_src]" alt='[name]' /><br />
 	<div itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">
		 Rated <span itemprop="ratingValue">[rating_value]</span>/5 based on <span itemprop="reviewCount">1</span> customer review
 	</div>

	<div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
		<span itemprop="price">[price]</span>
		<span itemprop="priceCurrency">EUR</span>
		<link itemprop="availability" href="http://schema.org/InStock" />In stock
	</div>

	Product description:
	<span itemprop="description">[content]</span>

	My Review:

	<div itemprop="review" itemscope itemtype="http://schema.org/Review">
		<span itemprop="name">[review_subject]</span> - by <span itemprop="author">[review_author_name]</span>,
		<meta itemprop="datePublished" content="<?php echo date( 'c', strtotime( $date ) ); ?>" />[date]
		<div itemprop="reviewRating" itemscope itemtype="http://schema.org/Rating">
			<meta itemprop="worstRating" content="[review_worst_rating]" />
			<span itemprop="ratingValue">[review_rating_value]</span>/
			<span itemprop="bestRating">[review_best_rating]</span>stars
		</div>
		<span itemprop="description">[review_description]</span>
	</div>
</div>

You can use the shortcode like this:

[productreview product_name="Schema.org WordPress Theme" img_src="http://wp-buddy-web.local/wp-content/uploads/2013/01/schema-coroporate-wordpress-theme-logo.jpg" rating_value="5" price="69 EUR" review_author_name="WP-Buddy" review_date="09.09.2013" review_subject="Best Theme Ever" review_worst_rating="0" review_rating_value="5" review_best_rating="5" review_description="Full integration of schema.org is great!"]A WordPress Theme that fully supports schema.org syntax[/productreview]

You can view an example here: Product Review Rich Snippets Example

Hidden Product

If you don’t want to make all product details visible to the enduser you can use meta-Tags instead. You can test it on the DEV site.

Hidden Product Attributes
<span itemscope="itemscope" itemtype="http://schema.org/Product">
  <meta itemprop="name" content="[name]" />
  <link itemprop="image" href="[image]" />
  <span itemprop="brand" itemscope="itemscope" itemtype="http://schema.org/Brand">
    <meta itemprop="name" content="[brand]" />
  </span>
  <meta itemprop="productID" content="[identifier]" />
  <meta itemprop="description" content="[description]" />
  <span itemprop="offers" itemscope="itemscope" itemtype="http://schema.org/Offer">
    <meta itemprop="price" content="[price]" />
    <meta itemprop="priceCurrency" content="USD" />
    <link itemprop="availability" href="http://schema.org/InStock" />
  </span>
  <span itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">
    <meta itemprop="ratingValue" content="[rating]" />
    <meta itemprop="bestRating" content="10" />
    <meta itemprop="worstRating" content="1" />
    <meta itemprop="ratingCount" content="1" />
  </span>
</span>

Syntax for Organization Logos

According to this blog entry, Google now supports schema.org markup for organization logos. You can use this syntax to show your logo in search results. But please note that Google “maybe” uses this image for the homepage. This doesn’t mean that it will work. If tested this a view times and for me Google never showed the logo in search results.

Schema.org Organization Logo Attributes
Schema.org Organization Logo Attributes
<div itemscope itemtype="http://schema.org/Organization">
  <a itemprop="url" href="[url]">My Organization Website</a>
  <img itemprop="logo" src="[logo]" />
</div>

Alternatively you can the following (hiding logo and link to the public):

<span itemscope itemtype="http://schema.org/Organization">
  <meta itemprop="url" content="[url]" />
  <meta itemprop="logo" content="[logo]" />
</span>

You can then use it like this in your posts or pages:

<div itemscope itemtype="http://schema.org/Organization">
  <a itemprop="url" href="[url]">Home</a>
  <img itemprop="logo" src="[logo]" />
</div>

No public rating

You can also use the rating without displaying anything to the public:

  <div itemprop="review" itemscope itemtype="http://schema.org/CreativeWork">
	  <meta itemprop="name" content="[itemreviewed]" />
	  <span itemprop="author" itemscope itemtype="http://schema.org/Person"><meta itemprop="name" content="[reviewer]" /></span>
	  <meta itemprop="datePublished" content="<?php echo date( 'c', strtotime( $dtreviewed ) ); ?>" />
	  <span itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">
		  <meta itemprop="ratingValue" content="[rating]" />
		  <meta itemprop="bestRating" content="[best]" />
		  <meta itemprop="worstRating" content="[worst]" />
		  <meta itemprop="ratingCount" content="1" />
	  </span>
  </div>

Just replace the code above with the original sourcecode of the rating shortcode and that’s it. Please note that Google does not like hidden things. So it is not sure that Google will display this rating on search results.

No public address

If you don’t want to show the address to the public, use this code for the address shortcode:

<span itemprop="address" itemscope itemtype="http://schema.org/PostalAddress">
	<meta itemprop="streetAddress" content="[streetaddress]" />
	<meta itemprop="addressLocality" content="[locality]" />
	<meta itemprop="addressRegion" content="[region]" />
	<meta itemprop="postalCode" content="[postalcode]" />
	<meta itemprop="addressCountry" content="[countryname]" />
</span>

You can use the same attributes that is used with the address shortcode:

Schema.org Address Shortcode Attributes
Attributes

Organization (no public)

This is the attribute list:

Attribute List

And this is the HTML-Code:

<div itemscope="" itemtype="http://schema.org/Organization">
	<meta itemprop="name" content="[name]" />
	<meta itemprop="name" content="[url]" />
	<meta itemprop="telephone" content="[telephone]" />
	<div itemprop="address" itemscope="" itemtype="http://schema.org/PostalAddress">
		<meta itemprop="streetAddress" content="[streetaddress]" />
		<meta itemprop="addressLocality" content="[locality]" />
		<meta itemprop="addressRegion" content="[region]" />
		<meta itemprop="postalCode" content="[postalcode]" />
		<meta itemprop="addressCountry" content="[countryname]" />
	</div>
</div>

When you named the Shortcode “Organization (no public)” you can use the shortcode like this:

[organizationnopublic url="" telephone="" streetaddress="" locality="" region="" postalcode="" countryname="" name=""][/organizationnopublic]

Software Application (no public)

This code adds SoftwareApplication schema.org syntax that is not visible to the public but by search engines.

This is the attribute list:

SoftwareApplication schema.org Attribute List

And this is the HTML code that can be used for the shortcode:

<div itemscope itemtype="http://schema.org/SoftwareApplication">
	<meta itemprop="image" content="[image]" />
	<meta itemprop="description" content="[content]" />
	<span itemprop="offers" itemscope itemtype="http://schema.org/Offer">
		<meta itemprop="price" content="[price]" />
		<meta itemprop="priceCurrency" content="[currency]" />
	</span>
	<span itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">
		<meta itemprop="ratingValue" content="[rating]" />
		<meta itemprop="bestRating" content="[best_rating]" />
		<meta itemprop="worstRating" content="0" />
		<meta itemprop="ratingCount" content="1" />
  	</span>
	<meta itemprop="inLanguage" content="[language]" />
	<meta itemprop="operatingSystem" content="[operatingsystem]" />
	<meta itemprop="applicationCategory" content="[category]" />
</div>

You can use the shortcode like this (if you named the Shortcode “SoftwareApplication”.

[softwareapplication image="" price="" rating="" best_rating="" language="" operatingsystem="" category="" currency=""][/softwareapplication]

No public recipe

This code adds Recipe schema.org syntax that is not visible to the public but by search engines.

This are the attributes:

Attribute List

This is the code:

<div itemscope itemtype="http://schema.org/Recipe">
	<meta itemprop="name" content="[name]" />
	<meta itemprop="author" content="[author]" />
	<meta itemprop="description" content="[summary]" />
	<meta itemprop="recipeCategory" content="[recipetype]" />
	<meta itemprop="image" content="[photo]" />
	<meta itemprop="thumbnailUrl" content="[thumbnail]" />
	<meta itemprop="datePublished" content="<?php echo date( 'c', strtotime( $published ) ); ?>" />
	
	<meta itemprop="prepTime" content="PT[preptime]M" />
	<meta itemprop="cookTime" content="PT[cooktime]M" />
	<meta itemprop="totalTime" content="PT[totaltime]M" />

	<div itemprop="nutrition" itemscope itemtype="http://schema.org/NutritionInformation">
		<meta itemprop="calories" content="[nutrition]" />
	</div>
	<meta itemprop="recipeYield" content="[yield]" />
	<?php
	foreach( explode( ',', $ingredients ) as $ingredient ){
		
		echo '<meta itemprop="ingredients" content="'. $ingredient .'" />';
	}
	?>
	<span itemprop="recipeInstructions" content="<?php echo esc_attr(do_shortcode( $content )); ?>" />
	
	<span itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">
		<meta itemprop="ratingValue" content="[rating]" />
		<meta itemprop="ratingCount" content="[count]" />
	</span>

</div>

You can find a preview and test on dev site of the plugin.

Minimalistic (hidden) product

This product only shows the name, the price and the rating of a product.

This is the attribute list:

Minimalisitc product attribute list
Minimalistic Product using schema.org with this attribute list

This is the code:

<span itemscope="itemscope" itemtype="http://schema.org/Product">
	<meta itemprop="name" content="[name]" />
	<span itemprop="offers" itemscope="itemscope" itemtype="http://schema.org/Offer">
		<meta itemprop="price" content="[price]" />
		<meta itemprop="priceCurrency" content="USD" />
		<link itemprop="availability" href="http://schema.org/InStock" />
	</span>
	<span itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">
		<meta itemprop="ratingValue" content="[rating]" />
		<meta itemprop="bestRating" content="10" />
		<meta itemprop="worstRating" content="1" />
		<meta itemprop="ratingCount" content="1" />
    </span>
</span>

Video

This product follows Googles example (that can be found here).

This is the minimalisitc attribute list:

Minimalisitc attribute list

<div itemscope itemtype="http://schema.org/VideoObject">
  <h3 itemprop="name">[title]</h3>
  <div itemprop="description">[content]</div>
  <p><img itemprop="thumbnailUrl" src="[thumbnail]" alt="[title]"/></p>
  <meta itemprop="uploadDate" content="<?php echo date('c', strtotime($date)); ?>"/>
</div>

Review with product and rating

Review Rating Attributes

<div itemscope itemtype="http://schema.org/Review">
	<div itemprop="itemReviewed" itemscope itemtype="https://schema.org/Product">
		<h2 itemprop="name">[product_name]</h2>
	</div>
	<p itemprop="reviewBody">[content]</p>
	<span>
		<span itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
			<meta itemprop="url" content="<?php echo esc_url( site_url() ); ?>"/>
			<span itemprop="brand" itemscope itemtype="http://schema.org/Brand">
				<meta itemprop="name" content="<?php echo esc_attr( get_bloginfo( 'name' ) ); ?>"/>
			</span>
		</span>
	</span>
	<span>Written by
		<span itemprop="author" itemscope itemtype="http://schema.org/Person">
			<span itemprop="name">[author_name]</span>
		</span>
		<meta itemprop="datePublished" content="<?php echo esc_attr( date( 'c', strtotime( $date ) ) ); ?>"/>
	</span>
	<p itemprop="reviewRating" itemscope itemtype="http://schema.org/Rating">
		We've rated this product with <span itemprop="ratingValue">[rating]</span>
		out of <span itemprop="bestRating">5</span> stars.
		<meta itemprop="worstRating" content="1"/>
	</p>
</div>

MusicRecording with rating

This would be the attribute list:

MusicRecording Attributes List

And this is the code:

<div itemscope="" itemtype="http://schema.org/MusicRecording">
	<a href="[url]" itemprop="name">[name]</a>
	<meta itemprop="url" content="[url]" />
	<meta itemprop="datePublished" datetime="<?php echo date( 'c', strtotime( $date ) ); ?>" />

	<div itemprop="byArtist" itemscope="" itemtype="http://schema.org/MusicGroup">
		<a href="[artist_url]" itemprop="name">[artist_name]</a>
		<meta itemprop="url" content="[artist_url]" />
	</div>

	<p itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">Rating:
		<span itemprop="ratingValue">[rating]</span> out of 5
		<meta itemprop="bestRating" content="5" />
		<meta itemprop="worstRating" content="1" />
		<meta itemprop="ratingCount" content="1" />
	</p>
</div>