Support

Account

Home Forums Add-ons Repeater Field repeater field with schema.org FAQPage Reply To: repeater field with schema.org FAQPage

  • Unfortunately, it still doesn’t work. The commas are not output.
    Here’s my complete code again:

    <?php 
    						  $rows = intval(get_field('faq'));
    						  if (have_rows('faq')) {
    							$count = 1;
    							?>
    							  <script type="application/ld+json">
    								{
    								  "@context": "https://schema.org",
    								  "@type": "FAQPage",
    								  "mainEntity": [
    								  <?php 
    									  while (have_rows('faq')) {
    										the_row();
    										?>
    										  {
    											"@type": "Question",
    											"name": "<?php the_sub_field( 'question' ); ?>",
    											"acceptedAnswer": {
    											"@type": "Answer",
    											"text": "<?php the_sub_field( 'answer' ); ?>
    										  }
    										<?php 
    										if ($count < $rows) {
    										  ?>,<?php 
    										}
    										$count++;
    									  }
    									?>
    								  ]
    								}
    							  </script>
    							<?php 
    						  }
    						 ?>