Skip to content

1231: Emit FAQPage schema from accordion blocks - #370

Open
svandragt wants to merge 1 commit into
mainfrom
1231-faq-schema
Open

svandragt wants to merge 1 commit into
mainfrom
1231-faq-schema

Conversation

@svandragt

Copy link
Copy Markdown
Collaborator

What

Adds FAQPage structured data for pages built from shiro/accordion blocks (Wikimedia #1231, the SEO/GEO schema gap). Verified there is no first-party FAQPage/JSON-LD emitter today.

The accordion blocks are static (markup saved into post content, no render callback), so this appends an FAQPage node to Yoast's existing schema @graph via the wpseo_schema_graph filter — no separate JSON-LD island. Questions/answers are read from the saved markup with DOMDocument (mirroring inc/editor/blocks/toc.php), because sourced block attributes like the accordion-item title are not available to parse_blocks() server-side.

  • Gated on the presence of a shiro/accordion block (has_block), so it follows the content wherever editors add accordions — no hardcoded URL list.
  • Question name is plain text (any <strong> in the title is stripped); answer HTML (<p>/<ul>) is preserved in acceptedAnswer.text.
  • Loosely coupled to Yoast: the filter simply doesn't fire if Yoast is inactive.

Files

  • inc/editor/blocks/accordion.phpnew, the schema builder.
  • functions.php — require + bootstrap the new file (existing manual lists).

Not in this PR

Note for the ticket

Google retired FAQ rich results in 2023, so this pays off as GEO / AI-citation structured data, not a Search Console rich snippet — acceptance shouldn't be graded on a rich result that will never appear.

Testing

  • php -l clean; phpcs (repo ruleset) clean on the new file.
  • Standalone self-check of the extraction (DOMDocument): 2 Q/A extracted from representative accordion markup, <strong> stripped from the question, <p>/<ul> preserved in the answer, and no-accordion / empty inputs yield nothing.
  • End-to-end render (Yoast graph on a live FAQ page) is coordinated with the foundation environment.

Refs #1231.

Adds FAQPage structured data for pages built from shiro/accordion blocks.
The blocks are static, so there is no render callback to hook; instead an
FAQPage node is appended to Yoast's schema @graph via the wpseo_schema_graph
filter, reading the saved question/answer markup with DOMDocument (sourced
block attributes such as the accordion-item title are not available to
parse_blocks() server-side). Gated on the presence of a shiro/accordion
block, so it follows the content wherever editors add accordions. Google
retired FAQ rich results in 2023, so this serves GEO / AI-citation
structured data rather than a search rich snippet.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@svandragt svandragt self-assigned this Aug 31, 2026
@svandragt svandragt changed the title Emit FAQPage schema from accordion blocks (#1231) 1231: Emit FAQPage schema from accordion blocks Aug 31, 2026
@svandragt
svandragt requested a review from Rayhatron August 31, 2026 10:32
@svandragt

Copy link
Copy Markdown
Collaborator Author

blocked by #372

@svandragt svandragt removed their assignment Sep 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant