Schema Shortcode Guide

The WPSSO Core plugin provides extensive support for hundreds of Schema types and can read data from dozens of supported third-party plugins and service APIs. The most popular Schema properties can be easily customized in the Document SSO metabox, and if required the [schema] shortcode can be used to define additional properties and types for sections of your content.

Please note that the [schema] shortcode is meant for advanced users only and is not required for WPSSO Core to create complete and accurate Schema JSON-LD markup for your content. You should avoid using the [schema] shortcode unless you're very familiar with https://schema.org markup and have very specific non-standard requirements. If you use the [schema] shortcode, make sure you always validate any change with the Schema Markup Validator and the Google Rich Results Test tool.

The [schema] shortcode can be used to define additional properties for the content. The following example defines an 'articleSection' property for the Schema Article type. Note that all shortcode attributes are considered to be Schema property names, except for the 'prop' and 'type' attribute names, which have special meaning (see below).

The [schema] shortcode can also be used to define a Schema type for a section of content, along with using that section of content for the Schema type description and its media properties. The following example defines a section of content as a Schema Map type. Please note that the 'type' value can be a WPSSO Schema type ID (as shown here) or a complete https://schema.org URL. When using the 'type' shortcode attribute, the 'prop' shortcode attribute is required (so the Schema type can be assigned to a Schema property). Note that WPSSO Core will automatically detect and include the image in the Schema map example content.

By default the [schema] shortcode replaces an existing Schema property value -- if instead you want to add a new element to a Schema property array, prefix the 'prop' attribute value with a '+' sign. For example, the following shortcodes will create an 'offers' array with two price specifications (see below for additional notes on using nested shortcodes).

The resulting JSON-LD array:

Please note that WordPress is not able to parse nested shortcodes, so the following shortcode structure is not supported by WordPress.

The WPSSO Schema Shortcode add-on does supports nested shortcodes using a numeric extension to work around the WordPress limitation. The add-on supports up to three levels of nesting by default, as the following example illustrates.

Practical Examples

Customer Reviews

You can add and maintain customer reviews directly in your content using the following example, but a much better (and more scalable) solution is to use a proper content rating / review plugin like the WPSSO Ratings and Reviews add-on, which adds customer ratings, reviews, replies and aggregate ratings markup automatically. The WPSSO Core Premium plugin also supports ratings and reviews from the WooCommerce and WP-PostRatings plugins.

Note that we are using Schema type IDs from WPSSO in this example -- using type="review" is the same as using type="https://schema.org/Review". Also note the use of a leading "+" sign in the first [schema] shortcode 'prop' attribute -- this tells the plugin to add this property as an array, so several reviews can be included. The plugin handles nested shortcodes, but WordPress does not, so nested shortcodes must be numbered for WordPress (schema, schema_1, schema_2, etc.). Don't forget to terminate the shortcode enclosure -- it can be easy to forget that closing [/schema] tag. ;-)

Aggregate Ratings

You can add and maintain aggregate rating values directly in your content using the following example, but a much better (and more scalable) solution is to use a proper content rating / review plugin. ;-) And in case you're using a non-supported rating / review plugin, that saves aggregate rating values in post meta, instead of using a shortcode you can also use a plugin filter to update the Schema aggregateRating property value.