-
How can I get the automated FAQ Schema code to work with my ACF blocks?
add_filter( ‘rank_math/json_ld’, function( $data, $jsonld ) {
if ( ! have_rows( ‘accordion’ ) ) {
return $data;
}$faq_data = [];
while ( have_rows( ‘accordion’ ) ) {
the_row();
$faq_data[] = [
‘@type’ => ‘Question’,
‘name’ => esc_attr( get_sub_field( ‘accordion_title’ ) ),
‘acceptedAnswer’ => [
‘@type’ => ‘Answer’,
‘text’ => esc_attr( get_sub_field( ‘accordion_panel’ ) ),
],
];
}if ( ! empty( $faq_data ) ) {
$data[‘faqPage’] = [
‘@type’ => ‘FAQPage’,
‘mainEntity’ => $faq_data,
];
}return $data;
}, 10, 2 );I can get some of this to show up and set the page to faq type but I am unable to get the mainEntity to update with all the FAQs/answers.
You must be logged in to reply to this ticket.