FAQ-Schema Support for ACF-Repeater on Product Categories

#727377
  • Resolved Daniel
    Rank Math free

    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)
  • Hello,

    We might need to take a closer look at the settings. Please edit the first post on this ticket and include your WordPress logins in the designated Sensitive Data section.

    Please do take a complete backup of your website before sharing the information with us.
    Sensitive Data Section

    It is completely secure and only our support staff has access to that section. If you want, you can use the below plugin to generate a temporary login URL to your website and share that with us instead:

    https://wordpress.org/plugins/temporary-login-without-password/

    You can use the above plugin in conjunction with the WP Security Audit Log to monitor what changes our staff might make on your website (if any):

    https://wordpress.org/plugins/wp-security-audit-log/

    We really look forward to helping you.

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

Viewing 1 replies (of 1 total)

The ticket ‘FAQ-Schema Support for ACF-Repeater on Product Categories’ is closed to new replies.