0

I'd wish to add some Rich Snippets to my Wordpress website. Where can I find the right documentation on this subject? I need to implement the Rich Snippet without an existing Wordpress plugin. I can develop my own if necessary.

I do know PHP, HTML and CSS.

Ben
  • 104
  • 14

2 Answers2

1

Rich snippet is generated by Search Engines by picking up your microdata schema you would have implemented in your theme.

You need to edit your theme, and implement any Schema you want to implement. If it is for example a product. You need to follow this schema https://schema.org/Product

    <div itemscope itemtype="http://schema.org/Product">
  <img itemprop="image" src="dell-30in-lcd.jpg" alt="A Dell UltraSharp monitor"/>
  <span itemprop="name">Dell UltraSharp 30" LCD Monitor</span>
  <div itemprop="aggregateRating"
    itemscope itemtype="http://schema.org/AggregateRating">
    <span itemprop="ratingValue">87</span>
    out of <span itemprop="bestRating">100</span>
    based on <span itemprop="ratingCount">24</span> user ratings
  </div>
  <div itemprop="offers" itemscope itemtype="http://schema.org/AggregateOffer">
    <span itemprop="lowPrice">$1250</span>
    to <span itemprop="highPrice">$1495</span>
    from <span itemprop="offerCount">8</span> sellers
    Sellers:
    <div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
        <a itemprop="url" href="save-a-lot-monitors.com/dell-30.html">
        Save A Lot Monitors - $1250</a>
    </div>
    <div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
        <a itemprop="url" href="jondoe-gadgets.com/dell-30.html">
        Jon Doe's Gadgets - $1350</a>
    </div>
  </div>
  ...
</div>

Using schema template in html, you can incorporate it into your theme, and populate your pages with dynamic content.

Please ask specific question about rich snippet or specific Schema if above information does not help you.

Added after your comment about Company/Organization

For that I recommend same approach but following schema as per https://schema.org/Organization

    <div itemscope itemtype="http://schema.org/Organization">
  <span itemprop="name">Google.org (GOOG)</span>
Contact Details:
  <div itemprop="address" itemscope itemtype="http://schema.org/PostalAddress">
    Main address:
      <span itemprop="streetAddress">38 avenue de l'Opera</span>
      <span itemprop="postalCode">F-75002</span>
      <span itemprop="addressLocality">Paris, France</span>
    ,
  </div>
    Tel:<span itemprop="telephone">( 33 1) 42 68 53 00 </span>,
    Fax:<span itemprop="faxNumber">( 33 1) 42 68 53 01 </span>,
    E-mail: <span itemprop="email">secretariat(at)google.org</span>
Members:
- National Scientific Members in 100 countries and territories: Country1, Country2, ...
- Scientific Union Members, 30 organizations listed in this Yearbook:
  <span itemprop="member" itemscope itemtype="http://schema.org/Organization">
    Member1
  </span>,
  <span itemprop="member" itemscope itemtype="http://schema.org/Organization">
    Member2
  </span>,
History:
</div>
Muhammad Asadullah
  • 3,735
  • 1
  • 22
  • 38
  • That is a really good idea.. I will try to apply your idea. It's not about products, but just organization information, social media, logo and stuff like that. But I already knew how to do that. Thanks for the support! I will keep you posted, if your answer passed :-) – Ben Oct 07 '15 at 14:31
  • It worked out pretty well.. I have made my own plugin with a lot of snippets.. Perfect! Thankyou.. – Ben Oct 08 '15 at 07:56
  • Great Ben! Thank you for your feedback and choosing my answer! – Muhammad Asadullah Oct 08 '15 at 20:22
0

I was searching for a way to add structured data to my website and came across this thread. Google prefers JSON-LD so it didn't quite meet my requirements. I eventually figured out how to add it using JSON.

Functions File:

function schema_mark_up () {
 while ( have_posts() ) : the_post();
            $post_id = get_the_ID();
            
            $name = get_the_title();
            $permalink = get_permalink();
            $images = array (get_post_meta($post_id, 'banner_picture', true),
                            get_post_meta($post_id, 'profile_picture', true)
                            );
            $street_address = array (
                                get_post_meta($post_id, 'address', true),
                                get_post_meta($post_id, 'address_1', true)              
                            );  
            $address_locality = get_post_meta($post_id, 'Suburb', true);
            $address_locality = get_post_meta($post_id, 'Province', true);
            $postal_code = get_post_meta($post_id, 'Postal Code', true);
            $address_country = get_post_meta($post_id, 'Country', true);
            $telephone = get_post_meta($post_id, 'Contact Number', true);
            
            $data = array (
                    '@context' => 'http://www.schema.org',
                    '@type' => 'LocalBusiness',
                    'image' => $images,
                    '@id' => $permalink,
                    'name' => $name,
                    'address' => array (
                        '@type' => 'PostalAddress',
                        'streetAddress' => $street_address,
                        'addressLocality' => $address_locality,
                        'addressRegion' => $address_region,
                        'postalCode' => $postal_code,
                        'addressCountry' => $address_country
                    ),
                    'priceRange' => 'ZAR',
                    'telephone' => $telephone
            );
            
            $json = json_encode($data);
            echo $json;
    endwhile;
}

In your header or whereever you want to call the code:

<script type="application/ld+json">
    <?php schema_markup (); ?>
</script>
Ragnaboy
  • 23
  • 4