1 回答

TA貢獻(xiàn)1936條經(jīng)驗(yàn) 獲得超7個(gè)贊
除了第一個(gè)元素之外,在每個(gè)元素之前添加一個(gè)逗號(hào)就足夠了。
嘗試添加:
<?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 關(guān)注
- 150 瀏覽
添加回答
舉報(bào)