Post data in separate divs with incrementing class using WP_Query

The main query has a loop counter build in which you can access via $wp_query->current_post. This counter starts at zero, so you would most probably add one to that count, something like $wp_query->current_post + 1

Also, you don’t need to separately count posts, that is also an already build in function which you can access with $wp_query->found_posts. This will return the total amount of posts in the query


wp_reset_postdata() should be used after the loop, not inside, so you should move wp_reset_postdata() to after endwhile