Blog · WebJi® India

How to Add Schema Markup in WordPress

Quick answer: Add schema markup to WordPress by setting a default schema type in an SEO plugin, or by printing a JSON-LD block from a child theme's functions.php on the wp_head hook. Validate the live URL in Google's Rich Results Test. One page should carry one primary type, and the markup must match what the page shows.
✓ In business since 2005✓ INR + GST billing✓ 24/7 Email Support — avg reply < 60 min
Small Indian startup team gathered around a laptop discussing their email inbox — how to add schema markup in wordpress

What schema markup does on a WordPress page

Schema is a shared vocabulary for describing what is on a page: this is a recipe, this is a local business, these are its opening hours. Search engines and AI assistants read it instead of guessing from the layout.

WordPress adds almost none by default. A theme prints a title and a post date; it does not tell anyone that the page is an Article, an Organization or a Product. The two routes below add that layer, and both write the same JSON-LD, so pick one and stay with it.

The plugin route: set the type once

An SEO plugin is the faster route and the right one if anyone else edits the site. Rank Math, Yoast and SEOPress all do the same three things; the labels differ.

  1. Install the plugin and run its setup, which sets Organization and WebSite schema site-wide.
  2. Pick a default type for posts (Article) and for pages (WebPage), so new content is covered without a decision each time.
  3. For one important page — a product, a service, an event — open the page, find the Schema tab in the editor sidebar, and add the specific type there.
  4. Fill only the fields you can verify: name, address, price, dates. Empty fields are dropped, wrong fields are worse than empty ones.
  5. View the page source and search for application/ld+json. If nothing appears, the plugin output is off or a cache is serving an old page.

The no-plugin route: JSON-LD in a child theme

Editing the parent theme directly loses the change at the next update. Create a child theme first, or use a code snippets plugin, then hook into wp_head.

  1. Create the child theme with a style.css that names the parent in a Template: line, or add the snippet with a code snippets plugin.
  2. Add a function to the child theme's functions.php that prints a script tag of type application/ld+json inside wp_head.
  3. Build the object as a PHP array and pass it through wp_json_encode(), so quotes and ampersands are escaped for you.
  4. Load the page and confirm the block appears once, in the head, with no PHP notice above it.

A minimal LocalBusiness node looks like this, with your own values: {"@context":"https://schema.org","@type":"LocalBusiness","name":"Example","telephone":"+91-XXXXXXXXXX","address":{"@type":"PostalAddress","addressLocality":"Jaipur","addressRegion":"Rajasthan","postalCode":"302021","addressCountry":"IN"},"url":"https://example.in/"}

Add schema to one page, not the whole site

Site-wide Organization schema belongs on every page. A Product, Event or FAQ block does not — it belongs on the page that shows it. In the functions.php route, wrap the output in a condition so it fires only where it should.

  • is_page( 42 ) targets one page by ID, which survives a slug change.
  • is_singular( 'product' ) targets every item of a custom post type.
  • is_page_template( 'page-contact.php' ) targets a template, useful for a contact or location page.
  • Never use is_page( 'contact' ) alone if a post shares the slug; the ID is unambiguous.

Article and FAQ schema on posts

Two nodes earn their keep on a normal blog post. Article carries the headline, author, publisher, dates and image. FAQPage carries question and answer pairs, and only when the questions are visible on the page.

The rule that catches most sites: the FAQ text in the JSON must equal the visible text, in the same order. If you drop a question from the page and leave it in the schema, the rich result disappears and Search Console reports a mismatch. Add mainEntity as an array of Question objects, each with acceptedAnswer.text.

Validate before you call it done

Two Google tools, used in this order, catch almost everything. Neither guarantees a rich result; they only confirm the markup is readable and complete.

  1. Paste the live URL into the Rich Results Test and run it. Fix every item marked as an error before looking at the warnings.
  2. Paste the same URL into the Schema Markup Validator to see the full graph, including nodes the theme adds.
  3. In Search Console, open Enhancements after two or three days. Errors appear per type, with the URL that caused them.
  4. Re-test one page after clearing the cache. A cached HTML page is the most common reason a fix looks like it did nothing.

Fix the four errors WordPress sites actually throw

What you seeWhyFix
Two Organization blocks with different namesPlugin default plus a hand-written blockKeep one. Remove the duplicate or stop the plugin's Organization output
JSON syntax error in the validatorUnescaped quotes in a hard-coded string, or a PHP warning printed inside the script tagBuild the array in PHP and encode it with wp_json_encode()
Markup present in source, missing in the testA page cache or CDN is serving the old HTMLPurge the cache, then re-run both tools
FAQ or rating mismatchThe schema lists content the page no longer showsMake the schema follow the visible page, not the other way round

Where to run schema safely

Test on a staging copy before the live site, because a PHP error in functions.php takes the whole site down, not one page. A WebJi® WordPress hosting account gives you a staging clone and SSH access to the files, so the child theme route is available without touching the live theme.

If the markup has to describe a local business, a service list or a product catalogue, the WordPress SEO service builds the schema and the content together. Email support@webji.services with the page URL and the type you want; support answers by email 24/7 in Hindi and English.

Frequently Asked Questions

How do I add schema markup to WordPress without a plugin?

Create a child theme and print a JSON-LD block from functions.php on the wp_head hook, building the object as a PHP array and encoding it with wp_json_encode(). Never edit the parent theme, because the change disappears at the next update.

Which schema type should a WordPress page use?

One primary type per page. Article for posts, WebPage for ordinary pages, Product for a product, LocalBusiness for a location, FAQPage when the page shows questions and answers. Site-wide Organization and WebSite schema go on every page.

How do I test schema markup in WordPress?

Paste the live URL into Google's Rich Results Test, then into the Schema Markup Validator for the full graph. Clear the page cache first, and check Search Console Enhancements after a few days for errors by type.

Why does my site show two Organization schemas?

An SEO plugin already outputs Organization and WebSite, and a hand-written block adds a second one with different details. Keep one source of truth: either configure the plugin or remove the manual block.

Does schema markup guarantee a rich result?

No. Valid markup makes a page eligible; Google decides whether to show the enhancement. Schema that describes content the page does not display, or that fails validation, will not be shown at all.

Need help with this?

WebJi® support does it for you — free. Talk to our Jaipur team →