<?php if( have_rows(‘faqs’) ): ?>
<?php $faqSchema = ”;
while( have_rows(‘faqs’) ): the_row();
$faqSchema .= ‘{
“@type”: “Question”,
“name”: “‘.get_sub_field(‘heading’).'”,
“acceptedAnswer”: {
“@type”: “Answer”,
“text”: “‘.get_sub_field(‘content’).'”
} },’;
endwhile;
?>
<script type=”application/ld+json”>
{
“@context”: “https://schema.org”,
“@type”: “FAQPage”,
“mainEntity”:[
<?php echo rtrim($faqSchema,’,’); ?>
]
}
<?php endif; ?>
</script>