I have a basic counter going that echoes out the number for each paragraph in my content, and I need to find the total number of loops for my counter...
<?php
$count = 0;
// check if the repeater field has rows of data
if( have_rows('each_class_event') ):
// loop through the rows of data
while ( have_rows('each_class_event') ) : the_row(); ?>
<?php $count++; ?>
<div class="eachOne">
<div class="classInfo">
<p>Session <?php echo $count; ?></p>
</div>
</div>
in the paragraph I need it to be something like:
<p>Session <?php echo $count; ?> of <?php echo $totalCount; ?></p>
对我有用的解决方案是将WordPress中的自定义字段视为数组,并使用此数组。
<p>Session <?php echo $count; ?> of <?php echo count( get_field('each_class_event') ); ?></p>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.