Lesson 2: How to create a Global Snippet

In this video I want to show you how you can work with the Global Snippets functionality to automate Structured Data generation in WordPress.

Structured Data Training 5: Global Snippets and how to automate Structured Data Generation

Transcript

Hey and welcome back. Nice to have you in the second lesson of module 2.

I’m Florian, the developer of SNIP, the Rich Snippets and Structured Data Plugin for WordPress. If you want to use the plugin, please feel free to follow the link that you can find in the description area.

In this video I want to to tell you how you can automate the generation of structured data.

Single snippets

In the first lesson of module 2 I thought you how you can integrate a single Structured Data Type into a singe post, page or custom post type. Wasn’t that easy? We didn’t need a single line of code! Good job!

But what if you want to integrate a Structured Data Type to more than just one single post? What if you want to add it to all posts, to posts that have certain category or a certain tag?
You don’t want to add a snippet to every single page over and over again, do you?

Global Snippets

That’s why I’ve created a functionality that I’ve called „Global Snippets“. The procedure is approximately the same as for the single Snippets but it has more interesting features that make your life super easy. And I’m going to show them to you now.

All you need to do is to go to the „Global Snippets“ menu in your dashboard. And there you go! You can now create a Structured Data Type and select where it should appear. I’ll show you this in more detail soon.

Predefined Snippets

But before that I would also like to mention that my plugin ships with some pre-created Global Snippets that most people use. They’re not installed automatically but the plugin will ask you if it should install them.
Just hit the „Install“ button on top of that page and you’ll see that they will magically appear.

For now you’ll find a Review for a Product, a Product for WooCommerce, a Recipe, an Article and an Organization markup. Some of them are not yet published as I can’t know what you do on your website.

Please also note that this view can change in the future as well. So it might be that I integrate more and more predefined snippets here

Ok. Let’s take a closer look into the Article snippet.

Edit a Global Snippet

As you can see, the Structured Data Generator is also here. You have seen it in the last video where we created a single snippet on a singular post, too.

There are two things that make Global Snippets so powerful. The first one is that you don’t need to fill every field by hand. You can choose from a variety of variables.

Let’s take a closer look at the headline property of the Article Schema. As you can see I’ve chosen to use the „Post title“ for the headline. So if we integrate this Global Snippet into all of our posts automatically, it will use the post title from the current post to build Structured Data for the Article.

Again: The Global Snippets functionality allows you to create one Schema that can be used on multiple posts, pages and custom post types. It replaces the variables with the current values from each post.

But how does we tell the Global Snippet where it should be integrated?

The Position Metabox

Just scroll down a little further till the „Position“ metabox appears. Here you define a set of rules to determine which pages will use the above schema.
In my case the snippet will be integrated when the post type is equal to „posts” or „pages“.

If we now test a post with Googles Structured Data Test Tool you see that the headline has the value of the current post title.

If we check a page, it’s almost the same. The only difference is that the headline property has now a different value. The value of the page title.

Field Types

The plugin comes with a variety of field types that you can use. For text values you can integrate things like the post title, the excerpt, the author name, and a lot more.

The Field Type select box changes with every schema property and intelligently shows you only the fields that are allowed here. So in this screenshot you see that you cannot enter your own text or a post title for example. This is because the aggregateRating property does not allow text here. It would result in an error later. So the plugin is smart enough to avoid errors upfront.

Let’s say you’re using a third party plugin that writes data into the post meta table of a post. You can use this data, too! All you need to know is the names of the fields in the database the plugin uses. In my example I use a rating plugin that writes the overall value in the post meta field called _ph_rating_value. So I’ve chosen „Post meta field“ from the dropdown and entered the name. That’s it!

Some of the very popular plugins are supported as well. For example if you’re using WooCommerce you can choose to integrate the comments on products as reviews or – as shown in this example – use the overall rating for an aggregateRating property.

Endless possibilities!

Yes, you can build nearly anything with the plugin. And if this is not enough you can tell your developer that the plugin is extendable via WordPress action- and filter hooks to integrate all the stuff you need and that is not yet supported officially. Super easy!

Summary

Now. Let’s sum up what you’ve learned in this video.

  • You now know what the term “Global Snippets” means and
  • that you can use the functionality to generate structured data automatically.
  • You have learned that you can set up rules and rulesets to exactly define where a snippet should appear on your WordPress site.
  • The built-in field type dropdown intelligently suggests what value could be entered for a field. It allows you to automatically choose from a variety of variables like the post title, post content, author names and a lot more. Some third party plugins like WooCommerce and Yoast SEO are supported as well.
  • If you need custom data you can use the „post meta field type“ to fetch data from other plugins like Advanced Custom Fields. If that is not possible (for example if the data has a strange data format) you can always ask a developer to extend SNIPs functionality by using Action- and Filter-Hooks to extend its functionality even more without loosing its update capability.

Isn’t this great? You will not find another plugin that can all this! Believe it or not. You can do even more with SNIP – The Rich Snippets and Structured Data Plugin for WordPress.

In the next video I’m going to show you how you can overwrite values from Global Snippets. You should watch the video even if this sounds strange to you now. There are a lot of use cases where overwriting global snippets makes totally sense. For example for Recipe markups. So I hope I will see you in the next video!

Cheerio!