Check for first post using wp_query
<p>I am new to wordpress. Inside the loop I want to check if the post is the first result from the query.</p>

<p>This is my code.</p>

<pre><code>&lt;?php
    $args = array('post_type' =&gt; 'home-slider', 'posts_per_page' =&gt; 6, 'order' =&gt; 'ASC');
    $query = new WP_Query( $args );
    while ($query-&gt;have_posts()) : $query-&gt;the_post();
?&gt;

&lt;?php if (  ) { ?&gt; // check if first post
    &lt;p&gt;TEST&lt;/p&gt;
&lt;?php } else { ?&gt;
    &lt;p&gt;TEST123&lt;/p&gt;
&lt;?php } ?&gt;

&lt;?php
    endwhile;
?&gt;
</code></pre>

<p>Thanks in advance.</p>