1. Home
  2. Knowledge Base
  3. SEO Suite
  4. How to Use ACF Repeater Fields to Automate FAQ Schema

How to Use ACF Repeater Fields to Automate FAQ Schema

In this knowledgebase article, we’ll show you how to use ACF Repeater Fields to Automate FAQ Schema.

1. Firstly you need to Install Rank Math.

Rank Math Plugin

2. Once you have installed Rank Math then you need to install the Advanced Custom Field. Ensure that the ACF module is enabled in WordPress Dashboard > Rank Math > Dashboard

Advanced Custom Fields PRO

3. Create a new ACF Repeater Field. In order to do so go to Custom Field > Field Groups. Then click on Add New.

Field Groups

Then create a new field as FAQ Fields and click on Add Field.

Add New Field Group

Fill in all the details and select the Field Type as Repeater.

Field Type- Repeater

4. Create a new field for FAQ Question in the Repeater field.

FAQ Questions

5. Similarly create a new field for FAQ Answer in the Repeater field.

FAQ Answer

6. Add a new Post and fill the FAQs using the newly created fields.

Fill the FAQ in Post

7. Enter this code in the theme’s functions.php file:

add_filter( 'rank_math/json_ld', function( $data, $jsonld ) {
if( ! have_rows('acf-repeater-faq') ) {
return $data;
}
$data['faqs'] = [
'@type' => 'FAQPage',
];
while( have_rows('acf-repeater-faq') ) {
the_row();
$data['faqs']['mainEntity'][] = [
'@type' => 'Question',
'name' => esc_attr( get_sub_field('faq_question') ),
'acceptedAnswer' => [
'@type' => 'Answer',
'text' => esc_attr( get_sub_field('faq_answer') ),
],
];
}
return $data;
}, 10, 2 );

8. Change the acf-repeater-faq to the field created in step 3 at line2.

9. Change faq_question to the field created in step 4 at line 12.

10. change faq_answer to the field created in step 5 at line 15.

This is how you can use ACF Repeater Fields to Automate the FAQ Schema. If you have any questions – feel free to reach out to our support team.

Was this article helpful?

Still need help?

?

Submit Your Question

Please give us the details, our support team will get back to you.

Open Ticket

Related Articles