How to Add JSON-LD Schema to WordPress: Plugins, Header Snippets, and Validation


🧭 Introduction

You’ve already learned how structured data turns your content into a machine-readable knowledge graph in the Schema & Structured Data guide.

Now it’s time to make it real — by adding that JSON-LD schema code to your WordPress site so that Google, Bing, and AI engines can actually see your entities and relationships.

This guide walks you step-by-step through:

By the end, you’ll have a living, breathing knowledge graph built directly into your /geo/ pages.


🧩 Step 1 — Get the Right JSON-LD Schema Code

Before you add anything to WordPress, you need the JSON-LD snippet that describes your content.

There are three easy ways to get it:

Option A: Use Schema.org’s Generator

  1. Visit https://schema.org.
  2. Find your schema type — Article, WebPage, DefinedTerm, etc.
  3. Click the “Generate JSON-LD” link or copy the example snippet.
  4. Update names, URLs, and @ids to match your site (for example, https://kentlundin.com/geo/#geo).

Option B: Ask ChatGPT to Write It

Copy this prompt into ChatGPT or your preferred AI tool:

🧩 Prompt: Generate My Website Schema (Ask Me Questions First)

You are a Schema.org and Generative Engine Optimization (GEO) assistant.
Your task is to help me create both global and per-page JSON-LD schema for my own website project.
My website is not about GEO — it can be any topic.

Your goal:

  1. Ask me questions to gather the information you need.
  2. Generate two separate JSON-LD blocks:
    • Global Schema: for my entire site
    • Per-Page Schema: for one specific page I choose
  3. Use @id patterns that are stable and based on my domain.
  4. Wrap each code block in <script type="application/ld+json">.
  5. After generating both blocks, give me a short checklist explaining where to paste them and how to test them.

🧠 Ask me these questions first (one at a time):

  1. What is your site URL (e.g., https://mydomain.com)?
  2. What is the main topic or purpose of your site?
  3. What is your core entity (the main concept, product, or service your site revolves around)? Describe it in one sentence.
  4. What page or section of your site serves as the main hub or pillar for that topic? (e.g., /recipes/, /travel/, /services/)
  5. Who is the author or organization (name, person, or brand)?
  6. What specific page should I create the per-page schema for? (Give the full URL and title.)
  7. What type of page is it? (Choose one: Article, CollectionPage, HowTo, Product, Service, FAQPage, Event, etc.)
  8. Provide a short description of that page’s content.
  9. What breadcrumb path should appear? (e.g., Home → Services → Pest Control).
  10. Do you want to include any external sameAs links (Instagram, YouTube, Wikipedia, LinkedIn, etc.)? If yes, list them.
  11. What SEO plugin does your website use? (Choose one: Yoast, Rank Math, or None.)
  12. Do you have datePublished and dateModified values? (If not, I’ll omit them.)

⚙️ Before you create the schema:

If the site uses Yoast SEO, follow these special instructions:

  • Do not include "WebSite" or "WebPage" schema for the current page — Yoast already provides these automatically.
  • You may include one "WebPage" type for the pillar or section page if needed (to define relationships like isPartOf → #website and about → #coreEntity).
  • All other nodes (DefinedTermSet, DefinedTerm, Article, Product, BreadcrumbList, etc.) are fine and can safely coexist with Yoast’s schema.

If the site uses Rank Math or no SEO plugin, include "WebSite" and "WebPage" normally.


🧩 Schema Structure to Follow

Global Schema (applies to all pages)

Include:

  • DefinedTermSet (the vocabulary for your site)
  • DefinedTerm (your core entity — the main concept or product/service)
  • Optional: WebPage node for your pillar/hub page
  • Optional: Organization or Person node for the author/owner

Use this pattern for @id values:

https://yourdomain.com/#vocab  
https://yourdomain.com/#coreEntity  
https://yourdomain.com/[pillar]/#pillar  

Per-Page Schema (specific to one page)

Include:

  • BreadcrumbList showing your navigation path
  • Main node (e.g., Article, Product, HowTo, Service, etc.) with:
    • "@id": {page_url}#article (or #product, #page, etc.)
    • "isPartOf": {"@id":"https://yourdomain.com/[pillar]/#pillar"}
    • "about": {"@id":"https://yourdomain.com/#coreEntity"}
    • "author": Person or Organization
    • Optional: "datePublished" and "dateModified"
    • Optional: "sameAs" links
    • Optional: references to glossary or related entity pages if applicable

🧾 When you have all my answers, generate:

  1. Heading: Global Schema JSON-LD
  2. <script type="application/ld+json"></script>
  3. Heading: Per-Page Schema JSON-LD
  4. <script type="application/ld+json"></script>
  5. A short checklist that includes:
    • ✅ “Paste the global schema in your site header (using HFCM or a Rank Math schema template).”
    • ✅ “Paste the per-page schema in that page’s header.”
    • ✅ “If using Yoast, leave out extra WebPage and WebSite types.”
    • ✅ “Purge your cache.”
    • ✅ “Test your URL in Schema Markup Validator to confirm all entities appear correctly.”

ChatGPT will output a valid JSON-LD block you can paste directly into your page.



⚙️ Step 2 — Insert Schema into WordPress

There are now three ways to insert JSON-LD schema into your WordPress site.
Choose the method that matches your setup.


Option A — Using Yoast SEO (most common)

If your site uses Yoast SEO, you already have some basic structured data in place (like WebSite, WebPage, Person, and Organization).
However, Yoast doesn’t let you manually edit or add JSON-LD.
To add your custom schema (like your global @graph, DefinedTermSet, or per-page entities), use a helper plugin.

✅ Recommended Method:

Use the Header Footer Code Manager (HFCM) plugin to add your extra schema on top of Yoast’s.

  1. Install Header Footer Code Manager (by 99robots).
  2. Go to HFCM → Add New Snippet.
  3. Name your snippet something like “Custom Schema – MySite”.
  4. Choose Location: Header.
  5. Under Display Conditions, choose:
    • For Global Schema: “Show on URLs containing /” (entire site)
    • For Section Schema: “Show on URLs containing /[your-section]/”
    • For Page Schema: “Show on URLs containing /[your-page]/”
  6. Paste your JSON-LD code inside: <script type="application/ld+json"> { ...your JSON-LD code here... } </script>
  7. Save and click “Update.”
  8. Clear any caches (WordPress, CDN, or browser).

Yoast and your custom schema will work together as long as you don’t duplicate types like WebSite or WebPage for the same page.
That means:


Option B — Header, Footer & Code Manager (No SEO plugin)

If you don’t use Yoast or Rank Math, this is the simplest way to manage your schema.

  1. Install Header Footer Code Manager (by 99robots).
  2. Create a new snippet.
  3. Name it “Global Schema”.
  4. Choose Location: Header.
  5. Select your display conditions (whole site or specific URLs).
  6. Paste your JSON-LD code inside the <script> tag and save.

This injects your structured data directly into the <head> area of your site.


Option C — Manual Theme Insertion (Advanced Users)

If you want total control:

  1. Open your theme’s header.php file.
  2. Find the closing </head> tag.
  3. Paste your JSON-LD schema block above it.
  4. Save and upload the file.

Only use this if you’re comfortable editing PHP files.


🧪 Step 3 — Validate and Debug Your Schema

Before You Validate: Clear Your Cache

If your new schema doesn’t show up in the validator, your page is probably serving an old cached version. Do these three things, then test again:

  1. Purge your WordPress cache — in the admin bar, open your caching plugin (e.g., LiteSpeed Cache, WP Super Cache, W3 Total Cache, WP Rocket) and click Purge All Caches.
  2. Purge your host or CDN cache — hosts like SiteGround/WP Engine/Bluehost or CDNs like Cloudflare also cache pages. Click Clear Cache / Purge Everything.
  3. Force a fresh browser load — open in Incognito/Private or press Ctrl+Shift+R (Windows) / +Shift+R (Mac).

✅ Then View Page Source and search for @graph or @id. If you see your JSON-LD, test the live URL in Schema Markup Validator.

Once your schema is live, test it to confirm that Google sees your entities correctly.

  1. Go to Schema Markup Validator.
  2. Enter your page URL (e.g., https://kentlundin.com/geo/entities-and-knowledge-graphs/).
  3. Click Run Test.
  4. Review the results — you should see:
    • DefinedTermSet (#vocab)
    • DefinedTerm (#geo)
    • WebPage (#pillar)
    • Article (#article)
    • BreadcrumbList

Common Fixes

ProblemCauseSolution
Schema not showingCached version still loadingPurge WordPress, CDN, and browser caches
Duplicate schemaYoast auto-outputting JSON-LDDisable Yoast schema for that post type or switch to Rank Math
Warnings in validatorMissing optional propertiesSafe to ignore — focus on errors first
“Invalid @id”Wrong or missing stable @idUse your exact permanent URLs (e.g., /geo/#geo)

🔁 Step 4 — Maintain and Monitor

Structured data isn’t “set it and forget it.”
Re-validate periodically — especially when:

Keep your @id values consistent and your vocabulary synchronized with your Entity Inventory Template.


🧩 Summary

By now, your structured data isn’t just theory — it’s embedded knowledge.
Your WordPress pages now:

Together, this turns your site into a living knowledge graph — the foundation of true Generative Engine Optimization.


🔗 Related Resources


✅ Key Takeaways


Would you like me to create the JSON-LD block for this new /geo/adding-schema-to-wordpress/ page next — so it fits perfectly into your existing global + per-page schema structure?