1 回答
TA贡献1936条经验 获得超6个赞
除了第一个元素之外,在每个元素之前添加一个逗号就足够了。
尝试添加:
<?php if ($loop_counter > 0) echo ',' ?>
像这样的东西:
<?php if ( have_rows( 'fifth-section' ) ) : ?>
<?php while ( have_rows( 'fifth-section' ) ) : the_row(); ?>
<?php if ( get_sub_field( 'display' ) == 1 ) { ?>
"offers": {
"@type": "AggregateOffer",
"offers": [
<?php if( have_rows('tariffs') ): ?>
<?php
$loop_counter = 0;
while( have_rows('tariffs') ): the_row();
if($loop_counter%4 == 0){
if($loop_counter > 0){
?>
<?php } ?>
<?php }
$tariffs_subtitle = get_sub_field('subtitle');
$tariffs_cost = get_sub_field('cost');
?>
<?php if ($loop_counter > 0) echo ',' ?>
{
"@type": "Offer",
"name": "<?php echo $tariffs_subtitle; ?>",
"url": "<?php echo get_permalink(); ?>#price",
"price": "<?php echo $tariffs_cost; ?>",
"priceCurrency": "RUB"
}
<?php
$loop_counter++;
endwhile;
?>
<?php endif; ?>
<?php } else { } ?>
<?php endwhile; ?>
<?php endif; ?>
]
}
}
- 1 回答
- 0 关注
- 130 浏览
添加回答
举报