title: On while first item will have different class
body: <p>I have a simple while loop that will get the last 3 posts from WordPress.</p>
  <p>Now when I have output HTML from this PHP all 3 wrappers will have class active. I need to have this 'active' class only on the first one on the second and the third one won't have this class.</p>
  <p>I tried this when I add this class to wrapper but all wrapper will have this class.</p>
  <p>Is there any option for how I can add class 'active' only on the first post from this while loop?</p>
  <pre><code>&lt;?php
  $args = array(
      'post_type' =&gt; 'post',
      'posts_per_page' =&gt; 3,
  );
  
  $post_query = new WP_Query($args);
  
  if ($post_query-&gt;have_posts()) {
      while ($post_query-&gt;have_posts()) {
          $post_query-&gt;the_post();
          ?&gt;
              &lt;a href=&quot;&lt;?php the_permalink()?&gt;&quot; class=&quot;mySlides blog-slider active&quot;&gt;
      &lt;div class=&quot;img-wrapper&quot;&gt;
      &lt;?php echo the_post_thumbnail(); ?&gt;
          &lt;div class=&quot;content&quot;&gt;
              &lt;strong&gt;&lt;?php the_title();?&gt;&lt;/strong&gt;
              &lt;!-- &lt;div class=&quot;smalls&quot;&gt;
                  &lt;small&gt;Alexander Martin&lt;/small&gt;
                  &lt;img src=&quot;/wp-content/uploads/2021/02/smalls-divider.svg&quot;&gt;
                  &lt;small&gt;21min&lt;/small&gt;
              &lt;/div&gt; --&gt;
              &lt;p&gt;&lt;?php the_excerpt('20')?&gt;&lt;/p&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/a&gt;
  &lt;?php
  }
  }
  ?&gt;
  </code></pre>