wp-structured-data
Skill27 starsChanged 6 months agoMITView on GitHub
Use when emitting JSON-LD structured data (schema.org) from a WordPress theme or plugin — FAQPage, HowTo, ItemList, Recipe, Event, Product, Review — especially when the data lives in post meta / custom fields the SEO plugin can't see, OR when you must avoid duplicating the schema an SEO plugin (Rank Math, Yoast SEO, SEOPress) already outputs. Covers building the @graph in PHP, escaping with wp_json_encode, printing on wp_head, validating, and coexisting with SEO-plugin graphs. Triggers: \"add FAQ schema\", \"FAQPage JSON-LD\", \"add structured data\", \"schema.org markup WordPress\", \"rich results\", \"HowTo schema\", \"ItemList schema\", \"my FAQ rich result isn't showing\", \"duplicate Article schema\", \"Rank Math already outputs schema\", \"Yoast schema graph\", \"json-ld in head or footer\", \"wp_json_encode schema\", \"schema for custom fields\", \"breadcrumb schema duplicate\", \"validate structured data\". Not for: configuring an SEO plugin's built-in schema UI (use the plugin's own settings); meta tags / OpenGraph (that's SEO-plugin territory); on-page heading/markup SEO.
1 other project uses a version of this.
Adopted by
Most recently taken up by
- morrealev/wordpress-managertheir own version, first seen Mar 1, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- morrealev/wordpress-manager★ 8same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository21 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- wp-admin-browserSkill
- wp-background-processingSkill
- wp-build-toolsSkill
- wp-ci-qaSkill
- wp-coding-standardsSkill
- wp-databaseSkill
- wp-email-templatesSkill
- wp-freemiusSkill
- wp-github-flowSkill
- wp-guided-tourSkill
- wp-i18n-workflowSkill
- wp-multisiteSkill
- wp-org-submissionSkill
- wp-phpstan-stubsSkill
- wp-plugin-auditSkill
- wp-plugin-releaseSkill
- wp-plugin-testingSkill
- wp-woocommerceSkill
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 22
Always: check first what is already on the page:
- Very specific: line 36
Only add types the existing graph is missing (commonly FAQPage, HowTo, Recipe, custom ItemList).
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
WordPress Structured Data (JSON-LD)
Model note: Building a single schema type is mechanical (
haiku). Reach forsonnet/opusonly when reconciling a complex graph against an existing SEO-plugin graph.
Emit schema.org JSON-LD from theme/plugin code for content an SEO plugin can't generate on its own — without duplicating what the SEO plugin already ships.
When to use
- Content lives in post meta / custom fields (e.g. an FAQ repeater) and is stripped from the rendered content, so Rank Math/Yoast can't detect it.
- You render a custom section (table of contents, related items, steps) that warrants
ItemList/HowTo. - You need a schema type the SEO plugin doesn't offer on that template.
Rule 0 — never duplicate the SEO plugin's graph
Most sites already run Rank Math, Yoast, or SEOPress. They emit a @graph with WebSite, WebPage, Organization, Person, BreadcrumbList, and an article type (Article/BlogPosting/Product). Never re-emit those — duplicate/competing nodes confuse parsers and can suppress rich results.
Always check first what is already on the page:
# View source, then list the @type values in every ld+json block
curl -s "<url>" | grep -A99 'application/ld+json'Or in the browser console:
[...document.querySelectorAll('script[type="application/ld+json"]')]
.flatMap(s => { const j = JSON.parse(s.textContent); return (j['@graph']||[j]).map(n => n['@type']); });Only add types the existing graph is missing (commonly FAQPage, HowTo, Recipe, custom ItemList).
Pattern — build in PHP, print on wp_head
add_action( 'wp_head', function () {
if ( ! is_singular( 'post' ) ) {
return;
}
$faqs = get_post_meta( get_the_ID(), 'my_faqs', true ); // stripped from content
if ( empty( $faqs ) || ! is_array( $faqs ) ) {
return;
}
$questions = array();
foreach ( $faqs as $faq ) {
if ( empty( $faq['question'] ) ) {
continue;
}
$questions[] = array(
'@type' => 'Question',
'name' => wp_strip_all_tags( $faq['question'] ),
'acceptedAnswer' => array(
'@type' => 'Answer',
'text' => wp_kses_post( wpautop( $faq['answer'] ?? '' ) ),
),
);
}
if ( ! $questions ) {
return;
}
$schema = array(
'@context' => 'https://schema.org',
'@type' => 'FAQPage',
'mainEntity' => $questions,
);
echo '<script type="application/ld+json">' . wp_json_encode( $schema ) . '</script>' . "\n";
} );Key points
- Build a PHP array, then
wp_json_encode()— never hand-concatenate JSON.wp_json_encode()escapes for the<script>context; output is safe to print as-is. (PHPCS'sEscapeOutputsniff doesn't recognise it as an escaper; suppress it via a centralizedphpcs.xml.distexclude scoped to the file rather than scattering inline ignores.) @typetext:wp_strip_all_tags()for short names/titles;wp_kses_post()for answer/description bodies that may carry HTML.- head vs footer is irrelevant to Google — it parses JSON-LD anywhere. Use
wp_headto sit alongside the SEO plugin's graph (convention), orwp_footerif you need late data; both work. - Gate to the right context (
is_singular(), post type, a feature toggle) so schema only appears where the content does. - Mirror visible content. Schema must reflect what users actually see on the page (Google's structured-data policy). Don't emit FAQ schema for FAQs you don't render.
Common types worth emitting from code
| Type | Use for | Usually missing from SEO plugins? |
FAQPage | Q&A stored in meta / repeater | Yes, when stripped from content |
HowTo | Step-by-step tutorial sections | Often |
ItemList | TOC, related items, rankings | Yes |
Recipe | Recipe meta fields | Yes (unless a recipe plugin) |
Article/BlogPosting | The post itself | No — SEO plugin owns this |
BreadcrumbList | Breadcrumb trail | No — SEO plugin owns this |
Validate
- Google Rich Results Test (search.google.com/test/rich-results) — confirms eligibility per type.
- Schema.org validator (validator.schema.org) — structural correctness.
- Confirm there's exactly one node per type across all blocks (no duplicate
Article/FAQPage).
Common Mistakes
| Mistake | Fix |
Re-emitting Article/BreadcrumbList/Organization the SEO plugin already outputs | Never duplicate — inspect existing ld+json first; add only missing types |
| Hand-building the JSON string | Always build a PHP array + wp_json_encode() |
| FAQ schema present but FAQs not visible on the page | Mirror visible content — only emit schema for rendered content |
| Assuming head vs footer affects indexing | It doesn't; place by convention (wp_head) |
Inline // phpcs:ignore for the wp_json_encode echo | Centralize the EscapeOutput exclude in phpcs.xml.dist, scoped to the file |
| Emitting schema on every template | Gate with is_singular() / post type / feature toggle |
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

