Adding structured data to your site
Within this topic, we will look into how to add structured data specifically in WordPress. There are a number of ways that this can be achieved. Either through WordPress Plugins or via the WordPress editor in use.
1. Using WordPress Plugins
There are several plugins you may consider for use. In our case here, we will consider using the RankMath Pro plugin.
With the RankMath Pro plugin installed, navigate to the RankMath > Dashboard section
Enable the Schema module
Once the module is enabled, you will then have a “Schema Templates” segment displayed
With the above carried out, you can either set default schemas that apply globally to all elements of a specific post type or to a particular post type element.
(i) To set default schemas to a post type, navigate to the Rank Math > Titles and Meta section.
Within the “Post Types” segment, and on the schema type dropdown, you can specify the for the various post types. Below is a sample illustration for “Posts”:
(ii) In order to enable a schema type to a specific entity, in this case a post, you will need to begin by editing the post.
Access RankMath by clicking on the RankMath icon within the post
Click on the Schema tab
Here you will have a view of the default schema, of which we had earlier on specified as the global schema type for posts.
You can edit it to your preference.
Below is a sample video illustrating how to add a global schema to posts, editing it in individual posts as well as testing posts for rich results eligibility:
Alternatively, you can delete it and use the schema Generator to specify the schema type you would wish to use. Rank Math supports a number of different schema types. Below is a sample illustration on this:
You can also create custom schemas from the Custom Schema section illustrated below:
2. Via the WordPress editor
For this, you will need to first begin by generating or coding your schema markup code. You can use the Schema Markup Generator tool here or any other of your preference in order to quickly generate markup.
Once you have your markup ready, you will need to edit the post you wish to add the markup to and for the Gutenberg editor, add the custom HTML block on the post
Within it, then add the JSON-LD markup and save your changes.
If you are using the classic editor, then the code needs to be added under the “text” tab as illustrated below:
This method however only applies to single posts.
If you wish to also add markup globally for a specific post type, then this might require you to carry out some custom work on your theme files, which is a bit risky. We recommend involving a developer on this to avoid breaking things within your website.