Skip to content Skip to navigation
Back to the main support

Create your custom schema in JSON-LD with SEOPress PRO

In the same way as to mark your content with a schema, when selecting the schema type, choose “custom”.

A textarea appears allowing you to enter / paste your custom schema.

Do not forget to add the <script> tag, see example below.

SEOPress PRO keeps the type="application/ld+json" of the <script> tag and removes its other attributes. Since SEOPress PRO 10.4, an id attribute is kept too, so a script or a stylesheet of your site can target this block.

You can use all these dynamic variables in your code:

%%sep%% Separator
%%sitetitle%% Site Title (alias: %%sitename%%)
%%tagline%% Tagline (alias: %%sitedesc%%)
%%post_title%% Post Title (post, page, custom post type, alias: %%title%%)
%%post_excerpt%% Post excerpt (alias: %%excerpt%%)
%%post_content%% Post content / product description
%%post_thumbnail_url%% Post thumbnail URL – featured image
%%post_url%% Post URL
%%post_date%% Post date (alias: %%date%%)
%%post_modified_date%% Post modified date
%%post_author%% Post author
%%post_category%% Post category: the primary category when one is set (since SEOPress 10.4), otherwise the first one
%%post_tag%% Post tag
%%_category_title%% Category title
%%_category_description%% Category description
%%tag_title%% Tag title
%%tag_description%% Tag description
%%term_title%% Term title
%%term_description%% Term description
%%search_keywords%% Search keywords
%%current_pagination%% Current number page
%%page%% Page number with context (i.e. “Page 1 of 4”)
%%cpt_plural%% Plural Post Type Archive name
%%archive_title%% Archive title, as plain text since SEOPress 10.4
%%archive_date%% Archive date: month and year on a month archive; since SEOPress 10.4, the year on a year archive and day, month and year on a day archive
%%archive_date_day%% Day Archive date
%%archive_date_month%% Month Archive title
%%archive_date_month_name%% Month name Archive title
%%archive_date_year%% Year Archive title
%%_cf_your_custom_field_name%% Custom fields from post, page, post type and term taxonomy (replace your_custom_field_name by the name of your custom field). Since SEOPress 10.4, some keys are refused, see below
%%_ct_your_custom_taxonomy_slug%% Custom term taxonomy from post, page and post type (replace your_custom_taxonomy_slug by the slug of your custom taxonomy, eg: product_cat). Returns the primary term when one is set (since SEOPress 10.4), otherwise the first term
%%wc_single_cat%% Single product category
%%wc_single_tag%% Single product tag
%%wc_single_short_desc%% Single product short description
%%wc_single_price%% Single product price
%%wc_single_price_exc_tax%% Single product price taxes excluded
%%wc_sku%% Single SKU product
%%currentday%% Current day
%%currentmonth%% Current month
%%currentmonth_short%% Current month in 3 letters, eg: “Jan” for “January”
%%currentyear%% Current year
%%currentdate%% Current date
%%currenttime%% Current time
%%author_bio%% Author biography
%%author_first_name%% Author first name
%%author_last_name%% Author last name
%%author_website%% Author website
%%author_nickname%% Author nickname
%%_ucf_your_user_meta%% Author meta (replace your_user_meta by your own). Since SEOPress 10.4, some keys are refused, see below
%%currentmonth_num%% Current month in digital format
%%target_keyword%% Target keyword

You can add your own custom global variables by using this hook.

Custom fields and user meta in your schema

Since SEOPress 10.4, %%_cf_%% and %%_ucf_%% print nothing (an empty value) for:

  • keys starting with an underscore (hidden meta). Exception for %%_cf_%%: the WooCommerce and The Events Calendar fields _sku, _price, _regular_price, _sale_price, _stock, _stock_status, _global_unique_id (GTIN), _wc_average_rating, _wc_review_count, _EventStartDate, _EventEndDate, _EventCost, _EventURL, _EventVenueID and _EventOrganizerID remain available;
  • keys containing token, secret, password, passwd, nonce, api_key, apikey, two_factor, 2fa, activation_key, capabilities or user_level;
  • for %%_ucf_%% only, keys containing billing_, shipping_ or community-events-location.

Fields created with Advanced Custom Fields keep working, as ACF stores the value under the field name. To print a key refused by default, use the seopress_meta_tag_key_is_allowed filter, for example for a hidden field _book_isbn used as %%_cf__book_isbn%%:

add_filter( 'seopress_meta_tag_key_is_allowed', function( $allowed, $key, $type ) {
	if ( 'post' === $type && '_book_isbn' === $key ) {
		return true;
	}

	return $allowed;
}, 10, 3 );

Variables without quotes

Variables are replaced before the JSON is read. Written inside quotes, a variable outputs a text value. Written without quotes, it can output a number, a list or an object, for example a custom field holding a JSON array:

"workLocation": %%_cf_clinician_locations%%

Since SEOPress PRO 10.4, the live check of the schema editor (SEO > Schemas) accepts this syntax and reminds you: “Unquoted variables must output valid JSON on every page, such as [] when they have no value.” If the variable outputs nothing on a page, the property has no value and the schema of that page is invalid.

Make sure to test your schema once your post is published to avoid any errors.

The custom schema is available as manual or automatic from SEO > Schemas.

Where to find schemas?