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
}
?>
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.