When someone searches for information today, they increasingly turn to AI models like ChatGPT, Perplexity, or Gemini instead of Google. But these models don’t return a list of links. They synthesize an answer and cite the sources they trust most.
The question for anyone who runs a blog or content site is: how do you become one of those trusted sources? The answer lies in structured data, specifically JSON-LD Knowledge Graphs that help AI models understand not just what your content says, but how it connects to everything else you’ve published.
In this tutorial, you’ll build a PHP function that auto-generates a JSON-LD Knowledge Graph for every blog post on your site. There are no plugins, no external APIs, and just one function. It will detect entities in your content, map relationships between posts, and output a unified schema that both Google and AI models like ChatGPT can parse as a connected system.
Table of Contents
Why This Matters Now
AI search engines are replacing blue links with synthesized answers. When someone asks ChatGPT a question, it doesn’t return a list of URLs. It builds a response by citing the sources it trusts.
According to AccuraCast’s research on AI search citations, 81% of pages cited by AI engines use schema markup with JSON-LD as the dominant format. Pages with structured schema are 3 to 4 times more likely to be cited by ChatGPT or Perplexity than pages without it.
Most JSON-LD tutorials teach you to paste a static ';
}
The json_encode flags matter. JSON_UNESCAPED_SLASHES prevents URLs from getting escaped. JSON_UNESCAPED_UNICODE keeps non-ASCII characters readable for multilingual content. Without these, a single special character in a blog post title fetched from the database can break the entire JSON-LD block silently.
What the Output Looks Like in Production
Here is the actual JSON-LD generated by a real post on shinobis.com, a blog about AI tools and UX design:
{
"@context": "https://schema.org",
"@graph": [
{
"@type": "WebSite",
"@id": "https://shinobis.com/#website",
"name": "Designer in the Age of AI",
"description": "AI tools and real workflows from a designer who builds with AI.",
"url": "https://shinobis.com",
"inLanguage": "en",
"publisher": { "@id": "https://shinobis.com/#organization" }
},
{
"@type": "Organization",
"@id": "https://shinobis.com/#organization",
"name": "Shinobis",
"url": "https://shinobis.com",
"logo": { "@type": "ImageObject", "url": "https://shinobis.com/3117045.png" }
},
{
"@type": "Person",
"@id": "https://shinobis.com/#author",
"name": "Shinobis",
"description": "UX/UI Designer with 10+ years in banking and fintech.",
"url": "https://shinobis.com/en/about",
"jobTitle": "UX/UI Designer",
"sameAs": [
"https://www.linkedin.com/company/shinobis-ai",
"https://dev.to/shinobis_ia"
]
},
{
"@type": "WebPage",
"@id": "https://shinobis.com/en/one-year-with-ai-open-letter-to-designers",
"url": "https://shinobis.com/en/one-year-with-ai-open-letter-to-designers",
"name": "One Year with AI: Open Letter to Designers",
"isPartOf": { "@id": "https://shinobis.com/#website" }
},
{
"@type": "BlogPosting",
"@id": "https://shinobis.com/en/one-year-with-ai-open-letter-to-designers#article",
"headline": "One Year with AI: Open Letter to Designers",
"description": "One year ago I started this journey. Today I write to all designers who are still doubting, fearing, or ignoring AI.",
"abstract": "One year ago I started this journey. Today I write to all designers who are still doubting, fearing, or ignoring AI.",
"url": "https://shinobis.com/en/one-year-with-ai-open-letter-to-designers",
"datePublished": "2026-02-15T09:00:00-05:00",
"dateModified": "2026-03-20T14:30:00-05:00",
"inLanguage": "en",
"wordCount": 1842,
"author": {
"@type": "Person",
"@id": "https://shinobis.com/#author",
"name": "Shinobis",
"url": "https://shinobis.com/en/about"
},
"publisher": {
"@type": "Organization",
"@id": "https://shinobis.com/#organization",
"name": "Shinobis",
"logo": { "@type": "ImageObject", "url": "https://shinobis.com/3117045.png" }
},
"isPartOf": { "@id": "https://shinobis.com/#website" },
"mainEntityOfPage": {
"@type": "WebPage",
"@id": "https://shinobis.com/en/one-year-with-ai-open-letter-to-designers"
},
"about": [
{ "@type": "Thing", "name": "Midjourney", "url": "https://midjourney.com" },
{ "@type": "Thing", "name": "Prompt Engineering" }
],
"mentions": [
{ "@type": "Thing", "name": "Claude", "url": "https://claude.ai" }
],
"relatedLink": [
"https://shinobis.com/en/ai-is-not-going-to-take-your-job-your-comfort-zone-will",
"https://shinobis.com/en/the-designer-as-creative-director-of-machines"
],
"citation": [
"https://shinobis.com/en/ai-is-not-going-to-take-your-job-your-comfort-zone-will",
"https://shinobis.com/en/the-designer-as-creative-director-of-machines"
],
"keywords": ["Midjourney", "Prompt Engineering", "Claude"],
"workTranslation": [
{
"@type": "CreativeWork",
"@id": "https://shinobis.com/un-ano-con-ia-carta-abierta-disenadores#article",
"headline": "Un año con IA: carta abierta a los diseñadores",
"url": "https://shinobis.com/un-ano-con-ia-carta-abierta-disenadores",
"inLanguage": "es"
},
{
"@type": "CreativeWork",
"@id": "https://shinobis.com/ja/one-year-with-ai-open-letter-to-designers#article",
"headline": "AIと一年:デザイナーへの公開書簡",
"url": "https://shinobis.com/ja/one-year-with-ai-open-letter-to-designers",
"inLanguage": "ja"
}
]
}
]
}
Compare that to the static version: one BlogPosting with a headline and an author name. The difference isn't cosmetic. It's the difference between "there is an article" and "there is a knowledge node connected to an author with verified profiles, published by an organization, linked to related articles through citation relationships, covering specific topics, and available in three languages."
Testing Your Implementation
After deploying, validate at Google's Rich Results Test. Paste any post URL and look for your BlogPosting with all properties.
For a deeper audit, copy the

