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’re going to walk you through how to use ACF Repeater Fields to Automate FAQ Schema.

1 Install Rank Math Plugin

First, you need to Install the Rank Math plugin.

Rank Math Plugin

2 Install Advanced Custom Field

Once you have installed Rank Math, then install the Advanced Custom Field. Please ensure that the ACF module is enabled from WordPress Dashboard > Rank Math > Dashboard.

Advanced Custom Fields PRO

3 Create ACF Repeater Field

Create a new ACF Repeater Field. To do so, navigate to Custom Field > Field Groups. Click on Add New as shown below:

Field Groups

4 Create New FAQ Fields

Create a new field as FAQ Fields and click on Add Field as shown below:

Add New Field Group

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

Field Type- Repeater

5 Create Field for FAQ Question

Create a new field for FAQ Question in the Repeater field as shown below:

FAQ Questions

6 Create Field for FAQ Answer

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

FAQ Answer

7 Create a Post and Fill the FAQ Fields

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

Fill the FAQ in Post

8 Add the Code in functions.php File

Navigate to WordPress Dashboard > Appearance > Theme File Editor.

Navigate to Theme File Editor

In case, if it is a block theme you should navigate to WordPress Dashboard > Tools > Theme File Editor.

Theme File Editor in Block Theme

Now, select functions.php from theme files and add the below code snippet.

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 );
  • Change the acf-repeater-faq to the field created in step 3 at line2.
  • Change faq_question to the field created in step 5 at line 12.
  • Change faq_answer to the field created in step 6 at line 15.

Finally, click the Update File button.

If you still have any questions about how to use ACF repeater fields to automate FAQ Schema – you’re always more than welcome to contact our dedicated support team. They are available 24/7, 365 days a year…

Was this article helpful?

Still not using Rank Math?

Setup takes less than 5 minutes including the import from your old SEO Plugin!

Learn more about the PRO Version

Still need help?

?

Submit Your Question

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

Open Ticket

Related Articles