An FAQ page is a page that contains a list of questions and their respective answers with regard to a particular topic. When such pages are properly marked up, they may be eligible to appear as a “rich result” in Search.

Here’s an example of what an FAQ rich snippet may look like:

serp faq schema example WordPress

Add FAQ schema in WordPress

In this article, you will learn how to add FAQ Schema to WordPress using SEO plugins and without any plugins.

Add FAQ Schema in WordPress using Rank Math

Add An FAQ Using the WordPress Block Editor

Adding an FAQ Block using the WordPress Gutenberg Block editor couldn’t be easier.

While writing a post or editing a page, simply click the plus icon that is present on the right of the content area to add a block.

Adding FAQ block using-Block Editor

Clicking this will allow you to select from a list of available blocks that will depend on the plugins installed on your site. If you’ve installed Rank Math, you’ll be able to choose the FAQ Block.

Now that you’ve inserted the block, this is what you’ll see:

FAQ options 1

As expected, initially and most importantly you’ll be able to easily insert the question text and the answer content to that question respectively as well as an image.

Add FAQ Schema in WordPress using Yoast SEO

Open WordPress’ new block editor

Make a page in WordPress, add a title and an introductory paragraph. Now add the FAQ structured data content block. You can find the Yoast SEO structured data content blocks inside the Add Block modal. Scroll all the way down to find them or type ‘FAQ’ or ‘structured data’ in the search bar, which I’ve highlighted in the screenshot below.

how to structured data blocks Yoast SEO

Add questions and answers

After you’ve added the FAQ block, you can start to add questions and answers to it. Keep in mind that these questions live inside the FAQ block. It’s advisable to keep the content related to each other so you can keep the page clean and focused. So no throwing in random questions.

yoast seo content blocks faq add question

Keep filling, check and publish

After adding the first question and answering it well, keep adding the rest of your questions and answers until you’ve filled your FAQ page.
Once you are done, you’ll have a well-structured FAQ page with valid structured data.

Add FAQ Schema in WordPress without plugin

Add The Following Code to the functions.php File

In the WordPress dashboard, go to Appearance ➡ Theme File Editor and copy the following code into the child theme’s functions.php file and update it.

You must create a child theme before making any changes to functions.php file. Otherwise, the applied changes will be lost after each update.
Create child theme in WordPress step by step [without plugin]

As an alternative method, you can use the Code Snippets plugin to insert your codes into WordPress.

/** 
* FAQ Schema in WordPress by WPCookie
* https://redpishi.com/wordpress-tutorials/faq-schema-in-wordpress/
*/
add_filter( 'wp_footer', function ( ) {  ?>
<script>
let question = []
document.querySelectorAll(".question").forEach( e => question.push(e.innerText) )
let answer = []
document.querySelectorAll(".answer").forEach( e => answer.push(e.innerText) )
let faqInside = []
if ( question.length > 0 ) {
for (let i = 0; i < question.length; i++) {
faqInside.push(`{"@type":"Question","name":"${question[i]}","acceptedAnswer":{"@type":"Answer","text":"${answer[i]}"}}`)
}
let faq = String(faqInside)
let faqFinal = `{"@context":"https://schema.org","@type":"FAQPage","mainEntity":[${faq}]}`
var scriptschemafaq = document.createElement("script");
scriptschemafaq.type = "application/ld+json";
scriptschemafaq.innerHTML = faqFinal;
document.querySelector('footer').appendChild(scriptschemafaq);	
}
</script>
<?php });

Write your questions and answers using paragraph blocks

Add two pairs of paragraphs to the page for the number of questions and answers; write the question in the first paragraph and the answer in the second one. Then assign the “question” class to the question paragraph and the “answer” class to the answer paragraph.

Question for FAQ schema in WordPress
Answer for FAQ schema in WordPress

Once you are done, you’ll have a well-structured FAQ page with valid structured data.

If this article is difficult for you to read in text, you can watch the video version below.

Share this post
Maya
Maya

Hi, my name is Maya and I’m a WordPress plugin developer. I created this website to share some of the helpful codes that I’ve used in my own projects.
If you’re looking for a custom plugin for your website, you can contact me by clicking on Hire a developer in the menu. I’d love to hear from you.

Articles: 56

One comment

  1. Hi there,

    This is a helpful content.

    I am trying to implement an FAQ schema with WordPress\’s default \”details\” block. However, it does not get the answer text field in the schema validator. However, it works when using Headings and paragraph blocks.

    Do you know how to make it work with the default WordPress details block?

    Thanks

Leave a Reply

Your email address will not be published. Required fields are marked *