-
Hi There,
I just tried to follow your Tutorials to automate FAQ-Markups for ACF-Repeater Fields.
However I could not make it work.Field Names are:
-
prod-cat-faq for the Repeater itself
- prod-cat-faq-question for the FAQ Question
- prod-cat-faq-answer for the FAQ Answer
I tried the following codes:
add_filter( 'rank_math/json_ld', function( $data, $jsonld ) { if ( is_product_category() ) { $queried_object = get_queried_object_id(); if ( ! have_rows('prod-cat-faq', "product_cat_".$queried_object) ) { return $data; } $data['faqs'] = [ '@type' => 'FAQPage', ]; while ( have_rows('prod-cat-faq', "product_cat_".$queried_object) ) { the_row(); $data['faqs']['mainEntity'][] = [ '@type' => 'Question', 'name' => esc_attr( get_sub_field('prod-cat-faq-question', "product_cat_".$queried_object) ), 'acceptedAnswer' => [ '@type' => 'Answer', 'text' => esc_attr( get_sub_field('prod-cat-faq-answer', "product_cat_".$queried_object) ), ], ]; } } return $data; }, 10, 2 );
add_filter( 'rank_math/json_ld', function( $data, $jsonld ) { if( ! have_rows('prod-cat-faq') ) { return $data; } $data['faqs'] = [ '@type' => 'FAQPage', ]; while( have_rows('prod-cat-faq') ) { the_row(); $data['faqs']['mainEntity'][] = [ '@type' => 'Question', 'name' => esc_attr( get_sub_field('prod-cat-faq-question') ), 'acceptedAnswer' => [ '@type' => 'Answer', 'text' => esc_attr( get_sub_field('prod-cat-faq-answer') ), ], ]; } return $data; }, 10, 2 );
Can you help me in order to make it work?
Kind regards,
Daniel
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The ticket ‘FAQ-Schema Support for ACF-Repeater on Product Categories’ is closed to new replies.