How To Add Schema Markup To WordPress Without Plugin

How To Add Schema Markup To WordPress Without Plugin

You might already be familiar with what Schema markup is and the benefits it brings to your website. But have you ever felt overwhelmed with all the plugins available to add schema markup to your WordPress site? 

Don’t worry; I’ve got you covered! In this article, I’ll show you how to add schema markup to your WordPress website without using any plugins.

By the end of this article, you’ll be able to add schema markup to your site with ease and confidence. Let’s get started!

Different Formats for Schema

You may know what Schema is and how it helps you to rank better on google. However, are there 3 different formats of Schema that Google allows to use? 

Google recommended schema formats

Microdata

Microdata is a simple markup format that uses HTML tags to annotate content and provide additional information to search engines.

This format is supported by all major search engines and is the simplest way to add schema markup to your website.

RDFa

RDFa (Resource Description Framework in Attributes) is a format that uses HTML attributes to define entities and the relationships between them.

It’s a more complex format than Microdata but provides greater flexibility in describing content and relationships.

JSON-LD

JSON-LD (JavaScript Object Notation for Linked Data) is a lightweight data format that uses JavaScript to define entities and relationships between them.

It’s the preferred format for adding Schema markup to websites because it’s easy to understand, less prone to errors, and doesn’t require modification of your existing HTML code.

Among these 3, JSON-LD is the most easily generated and understood by Users and Google. Google encourages webmasters to use these formats more than any other.

Also, I’ll only show the method to apply JSON-LD Schema in this content.

Various Types of Schema For WordPress Site

You may already be familiar with some schema types thanks to plugins like RankMath and Yoast SEO. But you can use several different types of Schema on your WordPress site.

Here’s a list of some of the essential Schema types that you should consider implementing on your site:

  • Organization Schema: This type of Schema is used to provide information about your company, such as its name, logo, and contact information.
  • Article Schema: Use this Schema to help search engines better understand the content of your blog posts or articles. This includes information like the article’s headline, author, date published, and more.
  • Breadcrumb Schema: This Schema helps search engines understand the structure of your site and how the pages relate to one another.
  • Local Business Schema: If you have a physical location, such as a restaurant or store, use this Schema to provide information about your business, such as its address, phone number, and hours of operation.
  • Product Schema: If you have an online store, use this Schema to provide information about your products, such as the product name, price, and availability.
  • Video Schema: If you have videos on your site, this Schema can help search engines understand the content of your videos and how they relate to your site.

Many types of Schema are available, but these are some of the most crucial ones that you should consider incorporating into your WordPress website.

Utilizing Schema can provide search engines with a better understanding of your site and boost your chances of ranking higher in search results.

Generating and Validating Schema

As I mentioned, I won’t use any plugin for adding Schema; I’ll generate the snippet manually. Schema.org is the official site that ensures the structure and quality of the Schema. Even Google relies on the data structure of this organization to markup schema data.

You can use a free tool like Schema Markup Generator (JSON-LD)  or RankRanger to generate the Schema as you want. Choose the type of Schema you want to create and fill in the necessary information.

For example, I’m creating Schema for an embedded Video on my website. Using the TechnicalSEO, I’ll generate the code automatically.

generating schema with technical seo tool

Once you generate the script, you are ready to implement that on any website page. However, you should always test the code before you add that to your site.

Test the script with either Structured Data Testing Tool or Rich Rest Test to verify it.

testing the generated schema script

If they show no error in the code, then you are ready to take the following steps.

4 Methods for Adding Schema to WordPress Site Without Any Schema Plugin

RankMath, Yoast, or any other SEO plugin might not be dedicated to generating Schema, but they have it built-in. There will always be a limitation as these plugins are not dedicated. Also, you should make sure your site will be heavier by adding another schema plugin.

Now let’s go through these easy and effective methods to add Schema on the site one by one.

Method #1: Adding Schema With Gutenberg Editor

This is the easiest method to add schema markup without any plugins. Copy the code from the schema generator tool. Go to the page to which you want to add the schema code and press the “/” button. 

Then search for “Custom HTML” from the widget box. Paste the code in the box and hit update, and publish.

How To Add Schema Markup To WordPress Without Plugin 1

You can add the code to any section of the page. It won’t show on the front end so visitors won’t see any code.

Method #2: Adding Schema Using The Classic Editor

The first method should work for most websites, but it might crash for some reason. If you notice that your site is showing an “Updating failed. The response is not a valid JSON response.” error, you might want to use the classic editor to add the script.

Note- Updating fails can be happened due to your internet connection, so check them and fix them.

updating failed json unresponsive error message

Back to the guide, first, install and activate the classic editor. Open the post/page with the classic editor and view the page source in the “Text” view instead ofVisual,” then add the code on any website section.

I suggest putting it at the bottom of all the code to prevent breaking the content on that page.

Click the “Update” or “Publish” button, and it’ll add the Schema for that page.

Method #3: Adding Schema Using the WP Code plugin

Although I mentioned, I’ll show how to add Schema without a plugin; this is not a schema generator plugin. This is a code and snippet inserter plugin for universal use for a WordPress site.

Install the WPCode Plugin from WP Repository and activate it. Now you should find the plugin options in the left sidebar of the WP dashboard. Click on “Add Snippet” to add the Schema. 

add snippet under wpcode plugin for schema

You’ll see a lot of premade snippets but select “Add Your Custom Snippet” and click “Use Snippet.

add custom snippet

First, toggle on the snippet from “Inactive” to “Active” and also keep the snippet type as “HTML Code.

where to put the schema script in wpcode

You can choose between “Auto Insert” and “Shortcodes” for the inserting method. I recommend you keep that automatic, as it’ll choose the best method that fits the Schema. You can choose the location anywhere on the page, but I prefer to put additional code on the footer.

Also, you can trigger the code according to a device, but for better search ranking, keep that enabled for all devices.

placement and device for schema script

Now you have to declare where you want to add the Schema. The smart conditional logic block lets you choose a different section of the website where you can add the schema code. The most logical and universal way to put it’s the Page URL. 

Select Page URL and paste the page URL in the box. Click “Save Snippet,” and the script will be automatically added to the page.

You should always check if the script is running after the update with the Rich Results Test tool.

result after adding schema successfully

Method #4: Adding Schema Markup with Header.PHP and Custom Fields

It’s a trickier method than the other 3. You need to understand the website code well and how to edit that without disrupting the site structure. 

Before you apply this method, I would recommend you take a backup of the “header.php” file. You can revert everything by uploading the backup if something goes wrong while applying the method.

theme file editor

When you are on “header.php,” copy and paste the below code just above the closing head tag </head>. 

<?php
$schema = get_post_meta(get_the_ID(), 'schema', true);
if(!empty($schema)) {
echo $schema;
}
?>
adding the code over head tag

Now you need to enable custom fields to add the schema code. Go to any page or post on the site and open it in the editor. Click on the three dots in the top right corner to open the settings tab.

wp complete setting icon

Scroll down and click on “Preferences” a popup menu will appear, then select “Panels,” toggle on “Custom Fields,” then click “Enlable & Reload.

pannels and custom field setting under prefference

Now you can manually add schema code to your posts/pages without additional plugins. Open the page/post in the editor where you want to add the script. Scroll to the bottom of that page and find a “Custom Field” widget.

Click on “Add new” and name your custom field as “schema.” You must remember you should write the name exactly like “schema” this function is case-sensitive, and adding anything else might not work.

adding custom field under wp editor

Paste the script on the script on the value field and click “Add Custom Field.” You can add multiple schema codes in the same box. Just hit enter after each new script ending tag. Then update the content from WordPress settings.

adding schema type and script

Now if you check the URL with Rich Restul Test or Structured Data Testing tool, you should see the Schema is working fine.

FAQs

Is schema markup a ranking factor?

Yes, schema markup is a ranking factor. Search engine algorithms use schema markup to better understand and interpret web page content, which can influence how a page ranks in the search results. You can read how structured data works.

What are the best practices for using schema markup?

The best practices for using schema markup include all content is marked up, using valid structured data formats, avoiding duplication of content, and accurately representing the content on the web page. Additionally, you should use an established vocabulary such as Schema.org, for a better understanding of search engines. Make sure to use techniques such as microdata or JSON-LD, as these are the formats that search engines rely on most.

Conclusion

Adding schema markup to your WordPress website without plugins is a lot easier than you think! With the 4 methods outlined in this article, you have the tools you need to make your site stand out in search results and provide search engines with a better understanding of your content. 

From using the Gutenberg editor to add the code directly to your theme’s functions.php file to using a third-party tool, you have both easy and effective options. 

By following these steps, you’ll be able to add Schema to your site confidently and boost your site’s search rankings. So go ahead and try it out and see its positive impact on your site’s visibility and traffic!

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.