To get the total amount of items in a foreach
loop:
$looped_date = get_field('looped_data');
$total_items = count($looped_data);
echo $total_items;
Get the total amount of items from a custom $wp_query
loop:
$custom_query = new WP_Query($args);
$total_items = $custom_query->found_posts;
echo $total_items;
Number each item within a $wp_query
and foreach
loop:
$i = 1; // add this before the foreach
echo $i++; // add this once within the loop
Number each item within repeater (ACF). Learn more.
echo get_row_index(); // add this once within the row