-
In this tutorial https://rankmath.com/kb/how-to-use-acf-fields-in-schema-generator/, you only show to add ACF Field for FAQs. Right now I want to use ACF for my custom field, in our case is the tab for Table of Content (you can refer here: https://kawahbuku.com/titles/bajautopia-tales-of-borneos-sea-nomads/).
This is the code that I change a few places accordingly:
add_filter( ‘rank_math/json_ld’, function( $data, $jsonld ) {
if( ! have_rows(‘table_of_contents’) ) {
return $data;
}
$data[‘faqs’] = [
‘@type’ => ‘FAQPage’,
];
while( have_rows(‘table_of_contents’) ) {
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 );—-
I change the acf-repeater-faq with table_of_contents, but how about:
‘@type’ => ‘FAQPage’, — what should I put here?
‘name’ => esc_attr( get_sub_field(‘faq_question’) ), — what should I replace faq_question
‘text’ => esc_attr( get_sub_field(‘faq_answer’) ), — same here
Since in our ACF setup for Table of Content, we only have field name, that is table_of_content and we dont have any other element. How to custom your code here?
Regards,
Iskandar
The ticket ‘How to Use ACF Fields in Schema Generator’ is closed to new replies.