Add a class to every third wordpress post


Staff member
Im listing all wordpress posts in the blog category but trying to add a class called 'last' to every third 'fourcol' class


&lt;div class="container"&gt;
    &lt;div class="row"&gt;

    &lt;?php query_posts('category_name=blog&amp;showposts=10&amp;orderby=date&amp;order=dsc'); if ( have_posts() ) : while ( have_posts() ) : the_post(); ?&gt;

        &lt;div class="fourcol"&gt;
            &lt;a href=""&gt;&lt;h2 class="blogtitle"&gt;&lt;?php the_title(); ?&gt;&lt;/h2&gt;&lt;/a&gt;
            &lt;a href="#"&gt;&lt;img src="images/_scroll1.jpg"&gt;&lt;/a&gt;
            &lt;span class="date"&gt;12 May 2011&lt;/span&gt;
            &lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit.&lt;/p&gt;
            &lt;a class="more" href="#"&gt;Keep reading&lt;/a&gt;
                &lt;/div&gt;&lt;!-- fourcol END --&gt;

            &lt;?php endwhile; endif; ?&gt;
        &lt;/div&gt;&lt;!-- row END --&gt;
    &lt;/div&gt;&lt;!-- container END --&gt;

Hope this makes sense?