Add Schema To WordPress Code

How to add schema to WordPress

12 min read
David Attard

Adding schema to WordPress is an easy way to help Google better understand your website content. You’re helping the algorithm by using a markup language which has been specifically devised for search engines.

Google keeps making efforts into understanding content on websites, through Natural Language Processing techniques and more, then rewarding and penalizing accordingly.

Related: Coding for SEO

How do you add schema to WordPress?

It’s not complicated to implement this on your WordPress website, as you’ll see in this article. We’ll cover:

  • What is schema markup (microdata)?
  • Why is schema markup useful?
  • Methods for adding schema to your WordPress site.
  • Troubleshooting issues with schema markup.

Let’s go.

What is schema markup (microdata)?

While we’ve already discussed schema markup and structured data in some detail in a previous article, let’s refresh a bit with a short primer.

We all know and understand what HTML is — it’s a markup language designed to explain to browsers what and how they should display content to end users.

Schema markup was designed to overcome the limitations in conveying the semantics of web content to search engines. The idea is to give more meaning to the content being posted.

The problem is that while HTML explains how content should “look,” it doesn’t convey any meaning or semantics to the crawlers which are used to power search engines.

Search engine algorithms need to come up with their own ways to decipher and understand the actual content being displayed. Of course, they use plenty of advanced techniques to do this.

Yet, these techniques can only do so much.

Schema markup has been designed specifically to overcome such a limitation in conveying the semantics of content on the web. It is a series of markup data structures, which webmasters or owners of content can use to markup and explain in detail specific kinds of content and information presented on their sites.

Add Schema To WordPress Organization

The idea is to give more semantics, or meaning, to the content being posted.

While this can be used with regular articles (and in fact, there is markup which can be employed on articles), there are specific types of content which lend themselves better to such structured data. These include:

  • Creative works such as books, movies, music recordings, tv series, recipes, etc.
  • Embeddable objects which are not text such as videos, audio, images.
  • Events.
  • Organizations.
  • Persons.
  • Places such as local businesses, restaurants, etc.
  • Products and offers.
  • Reviews and ratings.

Here is a full listing of all the different types of content that can be represented using schema markup.

As an example, here is a description that can be applied to a movie:

<div itemscope itemtype ="">
<h1 itemprop="name">Solo: A Star Wars Story</h1>
<div itemprop="director" itemscope itemtype="">
Director: <span itemprop="name">Ron Howard</span> (born <span itemprop="birthDate">March 1, 1954</span>)
<span itemprop="genre">Science fiction</span>
<a href=" itemprop="trailer">Trailer</a>

As you can see, we are embedding a number of additional markup tags in the HTML. These tags are being used to give more meaning to the content we are showing.

Why is schema markup useful?

As mentioned further up in this article, schema is designed in a way that search engines can better understand content. But why is this useful for you as a web developer?

If you’ve been reading up on search engines these last few months, you probably already know that user search intent has become critical for rankings.

Search engines strive to display results which are able to accurately satisfy the user intent of a query.

With specific human-language queries becoming more pervasive — thanks to the prevalence of assistants like Google Assistant, Siri, Google Home, Alexa and all other sorts of “intelligent” assistance — algorithms need all the help they can get. By using schema markup, your website is given clear meaning to search engines, allowing them to present your results in the right context.

Adding schema to your WordPress site

Now that we understand what schema markup is, let’s see a few ways of how to actually get it implemented on your website. We will present various options so you can pick up the one that suits your need the most:

  1. Manually adding a few basic details to your theme.

  2. Add basic details with your SEO plugin.

  3. Use a theme that supports schema markup.

  4. Use a generic schema plugin.

  5. Using a niche-specific schema plugin.

Let’s take a look at each option.

1. Manually adding a few basic details to your theme

The simplest way to add schema markup to your WordPress site is to generate some markup using an appropriate tool available online with a few details about your site and organization. Then tweak your theme to output this data.

For example, the JSON-LD Generator allows you to create as detailed a structured data entry as you require.

By following the wizard and filling in the entries you can generate either a generic entry for your business, or specific entries for specific pages.

Add Schema To WordPress App
Photo: Schema App

Once you’ve entered all of the details, a JSON-LD (or JavaScript Object Notation for Linked Data) is created, which you should check against the Google Structured Data testing tool.

Don’t worry if you don’t know what JSON is, we’ll just be copying and pasting this into our website.

You should add the following essential items, but the wizard actually makes the filling of the information pretty simple to follow.

  • Business Category
  • Business Name
  • Address
  • Business Hours
  • Website
  • Hours of operation

…. and a few more details.

Once we have the JSON text, we’ll need to add this to our WordPress website as a script. The simplest way to do this is by adding a script tag to the header of your page. You can either edit the theme of your site to add the script, or use a plugin such as Insert Header and Footer.

Add the script as generated by the tool, save, and run your site through the Structured Data testing tool to make sure nothing was broken whilst installing the code on your site.

Add Schema To WordPress Settings

This is the most raw and basic way of adding schema markup. It’s for those who don’t want to add any plugins or perform any drastic changes on their site, but still have some structured data in place.

This is particularly suited to local businesses and organizations that want to make sure that their data is fully accessible to search engines.

2. Add basic details using your SEO plugin

Given that the schema markup is important for SEO, most SEO plugins support adding structured data to your website, at least at a basic level.

Yoast SEO, for example, allows you to add your organization details via SEO > Search Appearance:

Add Schema To WordPress Homepage

The SEO Framework plugin, our favourite plugin for search engine optimization, also has schema markup settings:

Add Schema To WordPress Output

Other SEO plugins will feature similar settings that will create schema markup data accordingly for your website.

3. Using a theme that supports Schema Markup

With schema markup becoming such a pervasive and important signal in search, some theme vendors have jumped onboard and are releasing products that support the output of schema markup by default.

Honestly, speaking, it is strange to me how little vendors are doing this. It would be great for customers if we could see more theme vendors picking this up.

For the sake of completeness, we will feature Schema Lite and The Schema, two themes that have markup built in.

Note: We haven’t used either of these themes ourselves, so we cannot make recommendations for or against their use.

During our testing, we could see that when running the demo sites through the structured data testing tool, the themes actually mark up each element in the site, such that it is giving an exact semantic meaning to ALL the elements of the site.

Add Schema To WordPress Testing

As can be seen in the above screenshot, the theme outputs various markup structured data that shows such items as:

  • Various pages
  • Sidebar entries
  • Organization
  • Header and footer
  • Site navigation elements
  • Blog items

We strongly believe that this is the direction all theme vendors should be taking.

4. Use a generic schema plugin

Just like there are some themes that are picking up structured data and adding it to their theme, there are also some plugins that are specifically designed to output various types of structured data.

One of the most popular schema plugins, which is also very highly rated, is the aptly-named Schema plugin. With an average 4.7 star rating and 50,000 active installations, it is quite a popular plugin for marking up your WordPress website with structured data.

The Schema plugin supports:

  • Knowledge Graph (organization, logo, company contact numbers and social profile links).
  • Creative Works (Article, BlogPosting, NewsArticle, Report etc.).
  • Blog, WPHeader, WPFooter, BreadcrumbList, About Page, Contact Page, Person and other WordPress elements.
  • Third-party WordPress plugins such as WooCommerce, Easy Digital Downloads and others.
  • Schema Review (through a free extension).

The beauty of this plugin is that it also has the ability to define new type outputs, which is great for developers and designers who want to add support for a specific type of schema markup within an existing website.

Add Schema To WordPress Automatically

To keep setup simple, the plugin also comes with a Configuration Wizard that allows you to quickly define the schema markup for your website / organization.

5. Using a niche-specific WordPress plugin

While the above plugins and methods can get you quite a good level of markup schema and even allow you to add your own types should you require, there are various niche-specific plugins that actually create markup schema for specific types of data.

We’ll be looking at a few such plugins.

Event Schema

The Event Schema plugin would be useful for those whose website generates a number of events that need to be marked up as the Event structured data.

The plugin also integrates with popular WordPress events plugins such as Events Manager, All-in-One Event Calendar, Event Organizer and EventON.

The expected result in search engines by using event schema on your site would be similar to this:

Add Schema To WordPress Google

All In One Schema Rich Snippets

Product rich snippets and reviews are also a great feature to have on your website. They generate better clickthroughs to your website from the search engine result pages.

You can see below how rich snippets, together with their ratings, stand out in Google. They include a star rating based on aggregate reviews, the actual product price, and whether the product is in stock or not.

Add Schema To WordPress Search

All In One Schema Rich Snippets integrates with various kinds of WordPress content types, including product, and generates schema markup accordingly.

Add Schema To WordPress Rich

Schema Review

Our final recommendation will be for generating reviews. This is particularly useful for sites selling products that also accept user reviews on the actual products, or review the actual product themselves.

If you’re getting good reviews, make sure they show up in the Google search results to encourage users to visit your product pages.

For this specific function of showing reviews, we’re going to suggest Schema Review by the same author of the Schema plugin, which we mentioned further up in this article.

Add Schema To WordPress Edit

As you can see, you can tweak the review markup for individual posts. However, this will only be based on the editor’s reviews.

On the other hand, if you’d like to show customer reviews, we can suggest WP Customer Reviews, which supports the ability to add customer reviews to your products, and generates outputs that reflect the markup schema showing aggregated reviews.

Troubleshooting problems with schema markup

Once you have set up markup schema, it’s time to run your site through the Structured Data testing tool.

It is important that your site has no errors or warnings.

Excess errors or incorrectly structured markup data can not only be problematic for search engines, but can also generate algorithmic penalties that will kill off organic traffic to your site.

Related: How to create a custom 404 page in WordPress

Multiple entries

This is by the far the biggest problem we encounter when it comes to markup schema. With multiple plugins supporting the generation of markup schema, one can easily have several plugins trying to generate the same data.

The result will be a mess of data, coming from different places and creating possibly conflicting or superfluous data.

If you see multiple entries for your organization, check which plugins are generating the schema by reviewing their settings; then disable the ones that you don’t want to appear.

Missing required fields

This is also a problem and is mostly likely to show up in the Google Search Console under the Structured Data report.

Fix missing required fields by identifying the items that are generating the errors, then updating them or disabling them (if you are not able to fix the problem).

Add Schema To WordPress Structured

Hidden schema markup

Some unscrupulous SEOs looking to get better search engine rankings have actually started abusing markup schema by generating structured data for items that are not actually visible on the page, or hidden from the actual browser.

If you are going to use schema markup, make sure that the items you are marking up are actually present on the screen.

If they aren’t, this goes against Google guidelines. It will result in an algorithmic penalty or manual review, both of which will severely demote your site.

Wrapping up

As we’ve seen above, there are plenty of ways to add schema to WordPress. We find that relevant plugins are the most recommended way to implement schema markup. However, if you are still in your research phase, we strongly suggest you opt for plugins that support schema markup natively rather than having to install third-party plugins to support structured data.

Once the algorithm crawls your site after you performed significant markup changes, observe the changes in organic rankings and tweak and optimize.

Compared with most optimization work, this is a relatively easy win!

Products Used