I have the following code:
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
<div class="item">
<?php the_post_thumbnail('full');?>
<div class="container">
<div class="carousel-caption">
<h1>
<?php the_title(); ?>
</h1>
<p>
<?php the_excerpt(); ?>
</p>
</div>
</div>
</div>
<?php endwhile; ?>
And I need to add the class "active" to the first div (next to "item")
Use a boolean variable to test, set it to true after first pass so that further loops will not mark it active
Add a flag: