a) Try to initialize the $count
variable before your loop:
$counts=0;
$loop = new WP_Query( array( 'post_type' => 'focus-areas', 'posts_per_page' => -1 ) );
while ( $loop->have_posts() ) : $loop->the_post();
$counts++;
echo $counts;
echo " - ";
endwhile;
b) or use the current_post
method (starts at 0
) of WP_Query
:
$loop = new WP_Query( array( 'post_type' => 'focus-areas', 'posts_per_page' => -1 ) );
while ( $loop->have_posts() ) : $loop->the_post();
echo $loop->current_post;
echo " - ";
endwhile;
Results:
On my install where I have 12 posts in a custom post type, case a) gives me:
1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 -
and case b) gives:
0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 -
ps: I’m not sure what you mean by 'get' => 'all'
but the usual way of fetching all posts is to use 'posts_per_page' => -1