Schema – Microdata for WordPress Articles

by • July 29, 2014 • Experts TalkComments Off on Schema – Microdata for WordPress Articles5319

You want a higher search rank? Implement Microdata on your website – simple as that. In fact, Schema has been proven to be so important to your search results, that you really should consider dedicating the time to do it, right now. SEO is code, nothing more, nothing less.

Please note that this article requires basic understanding of HTML and PHP. 
If you are unsure what to do, we advise you to contact a professional, 
or ask for professional assistance.

Also Read: Schema – Getting Started

On our last Schema guide, we learned how to implement microdata on static elements. These could range from the body’s tag all the way to assigning data-attributes for links, depending on their significance to our content. There are also different types of itemscope tags.

This time around, we are going to use the Schema attribute for articles (see documentation).

Introductory Points

We’ll be working under the template file single.php, or, if you have assigned different custom post types to your installation, look for single-posttype.php. There is also a more complex way of adding attributes requiring the use of javascript – which provides us with even more liberty.

Let’s stick with single.php: first off, define what the post-page is.

<body itemscope itemtype="http://schema.org/Article"> ... </body>

Crawlers and robots will immediately understand that the page is in fact an article.

Fortunately, we don’t need extra rules for our header, navigation, footer links, related and significant links, site names, pictures and anything else commonly available on every part of our website, because we have already defined those with basic microdata tags. Let’s proceed to our dynamic content.

WordPress Articles

Post titles on WordPress are defined by <?php the_title() ?>, working within a query. We can’t exactly go add a microdata tag in there. That bit of PHP is probably located within a heading tag <h1> or a span class, within your single.php template. Here’s what we can do:

<h1>
  <span itemprop="name">
    <?php the_title() ?>
  </span>
</h1>

Similarly, for our author, contributor, dates and anything else required (see further documentation).

Let’s say we want to dynamically connect our posts to a blog page (Schema=webpage):

<p>
  <a href="<?php the_permalink() ?>" itemprop="significantLink">
    <span itemprop="name">
      <?php the_title(); ?>
    </span>
  </a>
</p>

The premise is to include PHP markup within HTML markup, so you can effectively add data-attributes and microdata tags to classes and spans that hold your dynamic content in place.

Why do this? It’s like handing Google a map of your website.

Also Read: Schema – A Must for Improved Search Results

The examples depicted above are some of the things you can do with your WordPress installation and Schema. You should also check out our handy guide for implementing OpenGraph rules on your WordPress articles. Never forget to experiment in order to achieve the desired results.

Would you like to add anything to this story? Not sure how to implement Microdata on your website or online content? Drop us a comment below and we’ll be glad to help you out!

Related Stories:

Did you like this post? Subscribe to our Newsletter!

We don't spam, we will just send you a daily email with the best of our posts.




Comments are closed.