AEO

FAQPage JSON-LD Implementation: Match Your Markup to the Page

FAQPage JSON-LD is structured data that describes the questions and answers on a page using schema.org Question and acceptedAnswer objects. To help, every marked-up answer must appear verbatim on the visible page and meet accepted eligibility rules: one FAQPage per URL, visible content, no user-generated multi-answer threads. In my WordPress builds at webdev-saif.com, I generate the markup and the visible FAQ from one PHP array so the two cannot drift.

By Saif Al Jahanwebdev-saif.com

What FAQPage JSON-LD actually describes

FAQPage is a schema.org type for a page whose main purpose is a list of questions and answers. Its mainEntity property holds an array of Question nodes; each Question has a name for the question text and an acceptedAnswer, an Answer object whose text property carries the response. A suggestedAnswer can hold other answers, but acceptedAnswer is the pair engines lift. The graph belongs in a script tag of type application/ld+json in the head, printed server-side so it is present in the first HTML response. Since 2023 Google restricts FAQ rich results to authoritative government and health sites, so I never promise that snippet to a client. I still implement the markup because it is clean semantic data that answer engines can parse and quote, and it is cheap when generated from the same fields the page renders.

  • @type: FAQPage with a mainEntity array of Question nodes
  • Each Question carries name and an acceptedAnswer with a text value
  • Emitted server-side in a script type="application/ld+json" tag in the head
  • One FAQPage entity per URL; no duplicate graphs from stacked plugins

Visible-answer parity: the markup must mirror the page

Visible-answer parity means every question name and every acceptedAnswer.text in the graph must be readable by a visitor on that same URL. Answer engines quote structured data, but they also check that the claim can be verified on the page; a mismatch is a trust signal you do not want. Collapsed accordions are acceptable because the text exists in the HTML and a click reveals it. What fails is content that appears only inside the JSON-LD script, or an answer in the markup that has been shortened, reworded or expanded away from the visible version. In my builds I render the visible FAQ list and the JSON-LD from one PHP array, so parity is structural rather than something I check by eye before launch.

  • Every acceptedAnswer.text matches the answer a visitor reads on the URL
  • Collapsed accordion content is acceptable when it exists in the HTML
  • No answer that lives only inside the script tag
  • No paraphrasing between the visible text and the markup
  • Both surfaces generated from one PHP array

Eligibility rules that decide whether the markup is accepted

Acceptance is narrower than most people expect. The rules I apply come from schema.org and Google structured-data guidance, and they are worth stating plainly because answer engines reuse the same signals. One FAQPage entity per URL, with a mainEntity array of Question nodes only. Each Question needs a name and exactly one acceptedAnswer with a text value. The Q&A must describe content actually on the page and be visible to users. The type is not for forum threads where visitors submit their own questions and several competing answers; that is a different entity. I also check that no second plugin emits a competing FAQPage graph, because duplicate entities are harder to debug than a missing one.

  • One FAQPage per URL, mainEntity containing only Question nodes
  • Each Question has a name and exactly one acceptedAnswer.text
  • Every Q&A is visible to users on that page
  • Not for user-generated threads with multiple competing answers
  • No duplicate FAQPage graph from a second plugin

Implementing FAQPage JSON-LD in WordPress and PHP

In WordPress I keep a single PHP function as the source of truth for the FAQ. It returns an array of question and answer pairs, and that array is passed to two consumers: the template that prints the visible list and the callback hooked to wp_head that prints the JSON-LD. I encode with wp_json_encode using JSON_UNESCAPED_SLASHES, JSON_UNESCAPED_UNICODE and JSON_HEX_TAG; the last flag matters because a literal closing script tag inside an answer would otherwise terminate the block. The script is printed server-side, not injected by a tag manager after load, so crawlers see it in the first response. Answers are plain text without wrapper markup, which keeps the acceptedAnswer.text identical to what a visitor reads. I hook at a later priority to avoid colliding with an SEO plugin output.

  • One PHP function returns an array of question and answer pairs
  • The array feeds both the visible template and the wp_head JSON-LD callback
  • wp_json_encode with JSON_UNESCAPED_SLASHES, JSON_UNESCAPED_UNICODE and JSON_HEX_TAG
  • Print server-side; never inject FAQ markup through a tag manager
  • Plain-text answers so acceptedAnswer.text equals the visible copy

Markup that does not match the page, and how to avoid it

Most bad markup is not malformed; it is accurate JSON describing a page that does not exist. Common cases: a FAQPage listing six questions while the page shows three, an answer padded with claims the visible copy never makes, or promotional copy dressed up as a question and answer. Another is marking up a page whose real purpose is something else — a product page with a few FAQs is still a Product, not a FAQPage; put the Q&A in a separate Question set or a dedicated FAQ page and link to it. I also remove FAQ schema from paginated archive views where the question list changes, because the canonical URL cannot describe every variant. In my audits, deleting inaccurate markup improves trust more than adding another schema type.

  • Questions in markup missing from the visible page
  • Answers padded with claims the visible copy never makes
  • Promotional copy disguised as a question and answer
  • FAQPage applied to a page whose primary entity is a Product or Service
  • Q&A schema left on paginated views where the list changes

Verify the output, then watch for citations

Verification is specific and quick. Fetch the URL, copy the JSON-LD block and run it through the Schema.org Validator, then check each property against the rendered page with Google's Rich Results Test. I confirm the canonical, the question count and the answer text by eye; a PHPUnit assertion comparing the graph array with the visible FAQ array catches drift on future edits. In Search Console I watch the FAQ enhancements report for invalid items rather than assuming the markup is working. For AEO and GEO I also confirm that GPTBot, ClaudeBot and PerplexityBot are allowed in robots.txt, because schema nobody can crawl earns no citations. I am Saif Al Jahan, a WordPress and PHP developer in Mymensingh, Bangladesh, and this is the check I run before shipping through webdev-saif.com.

Frequently asked questions

Does FAQPage JSON-LD still earn rich results in Google?

Google restricted FAQ rich results in 2023 to well-known authoritative government and health websites, so for a typical business or portfolio site you should not expect the FAQ snippet. The markup is still valid schema.org data, and answer engines can use the clean question-and-answer pairs. Treat it as semantic clarity and citation support, not a guaranteed rich result.

Does the answer in the markup have to match the visible answer word for word?

Yes. Every acceptedAnswer.text in the graph should be the answer a visitor can read on that URL. If the page shows a shortened answer while the markup contains a longer one, that is drift, and it can cost rich-result eligibility and trust with answer engines. Generate both from one array so the visible text and the JSON-LD cannot diverge.

Can I mark up an accordion or collapsed FAQ?

Yes, provided the answers are present in the HTML and a visitor can reveal them by clicking. Collapsed accordion content is fine because it is still visible on interaction. What fails is content hidden from users entirely — text loaded only into the script tag, or answers injected by JavaScript that never render on the page.

Should I use FAQ schema for user-submitted questions?

No. FAQPage is for a page whose owner presents a fixed set of questions and accepted answers. Google guidance excludes forum-style pages where users submit their own questions and multiple answers, because the markup would describe content the site does not author or verify. For a support forum, use QAPage markup instead.

Where should FAQPage JSON-LD go in a WordPress build?

In WordPress, build one PHP array of question and answer pairs, render the visible list from it in the template, and print the same array as JSON-LD on wp_head with wp_json_encode. Use JSON_HEX_TAG to prevent a closing script tag in the text from breaking the block. Emit server-side, not through a tag manager after load.

Written by Saif Al Jahan, webdev-saif.com · Mymensingh, Bangladesh. Last updated .