Schema.org Markup for WordPress – Part 1

Tagged:
You can follow any response to this post though the RSS feed

I’ll start by saying…

There’s a lot more to be said on this subject, but I’ll summarise by saying that the best ideas implemented in the worst way possible are what keep us in business as web developers.

How anyone can possibly work out how to apply schema┬ámarkup to their own website without a week of nothing else to do is beyond me. It’s not that it’s complex, but the lack of information on the topic, particularly the website that’s supposed to be the authority on this makes it a real journey.

Anyway, after several hundred Google searches, we’re not sure if we feel enlightened or not.

The goal…

We recently made a decision to┬ámark up our own site with schema microdata, so we figured we’d document some of our experiences here.

For now, this snippet will┬áget you started if you’re using WordPress.

In particular, it will help search engines, scrapers & robots identify the differences between the types of content on your site. At this stage we’re only identifying pages, such as the difference between a technical article, a contact page or a portfolio. Individual page elements will have to wait for another day.

So there’s two steps here…

1) Place the function below into your functions.php file of the currently active theme…

 

Step 2) Add the following function call to the <HTML> tag in the header.php file located in your currently active theme.

 

Obviously we’re just referencing our function from step 1, so rename both the function and the call in steps 1 and 2 to whatever you like.

In our case, we’re inserting the function into the <html> tag, however there’s no right way to do this. Using the <body> tag, or a lower level element would be perfectly suitable in some situations.

In fact the more specific you are, the better the results. An example might be a page that contains multiple element types, such as articles, portfolios, blog entries and so on, like a home page. In situations like this, you may find that your markup will vary from most other pages on your site.

We’ll follow up shortly with another post showing how we identified some of the major elements throughout the site, such as navigation, headers, footers and so on.