我想在每个“id”中自动增加数字,我使用 ACF PRO 并选择了“Repeater”类型。我在下面尝试了这些代码,但它不起作用
<?php
$counter = -1;
if( have_rows('thongtin') ):
while ( have_rows('thongtin') ) : the_row(); $counter++ ?>
<?php get_template_part('templates/listmatcat'); ?>
<?php endwhile;
else :
endif;
?>
// The code in templates/listmatcat.php file
// I want to auto increase the number with #pr_file
<tr>
<td class="col col1">
<p class="name r"><?php the_sub_field('masomatcat') ?></p>
<a href="#pr_file<?php echo $counter; ?>" class="open_profile" rel="pr_dt"><img src="<?php the_sub_field('anhmatcattrai'); ?>" alt="" /></a>
<div class="clearAll"></div>
<a href="#pr_file<?php echo $counter; ?>" class="open_profile"><span class="active_s"></span></a>
</td>
<td class="col_center"></td>
<td class="col col2" style="text-align:left">
<div class="info"><img src="<?php the_sub_field('anhmatcatphai'); ?>" alt="" /></div>
</td>
</tr>```