title: Conditional Classes for Wordpress loop posts
body: <p>The css is already declared all I have to do is add some div classes. My theme uses an almost empty index.php with no html  but uses the get_template_part functions and calls various template parts for post types, so it has several loop{template-name}.php files. I have copied the one for the blog index and made a new loop with modifications. The index for my blog, calls the appropriate template with the modifications - <em>hooray</em>. However I have to be able to conditionally add div classes to make the conversion work completely.</p>
  
  <p>As the index.php for the blog runs through the loop I would like to be able to conditionally add one div class to the 1st returned post, and another div class to the 2nd and if the last post is odd then add a 3rd div class.</p>
  
  <p>Here is my loop-template4.php file.</p>
  
  <pre><code>&lt;?php /* If there are no posts to display, such as an empty archive page */ ?&gt;
  &lt;?php if ( ! have_posts() ) : ?&gt;
  &lt;div class="one"&gt; /*I added this line here and it works for not found.
      &lt;div id="post-0" class="post error404 not-found"&gt;
          &lt;h1 class="entry-title"&gt;&lt;?php _e( 'Not Found', 'smpl' ); ?&gt;&lt;/h1&gt;
          &lt;div class="entry-content"&gt;
              &lt;p&gt;&lt;?php _e( 'Apologies, but no results were found 
      for the requested archive. Perhaps searching will help find
       a related post.', 'smpl' ); ?&gt;&lt;/p&gt;
              &lt;?php get_search_form(); ?&gt;
          &lt;/div&gt;&lt;!-- .entry-content --&gt;
  &lt;/div&gt;        
      &lt;/div&gt;&lt;!-- #post-0 --&gt;
  &lt;?php endif; ?&gt;
  
  &lt;?php
  
  &lt;?php while ( have_posts() ) : the_post(); ?&gt;
      /**
        * I need to conditionally add one of 3 div classes here:  
        * odd `&lt;div class="one_half"&gt;`,   
        * even `&lt;div class="one_half last"&gt;`or   
        * odd and last, `&lt;div class="one"&gt;`  
        */
  
  &lt;div id="post-&lt;?php the_ID(); ?&gt;" &lt;?php post_class(); ?&gt;&gt;
  
  &lt;h2 class="entry-title"&gt;
  &lt;a href="&lt;?php the_permalink(); ?&gt;" title="
   &lt;?php printf( esc_attr__( 
       'Permalink to %s', 'smpl' ), the_title_attribute( 'echo=0' ) );
    ?&gt;" rel="bookmark"&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;
  &lt;/h2&gt;
  
  
  &lt;?php do_action('skeleton_post_meta'); ?&gt;
  
  &lt;?php if ( is_archive() || is_search() ) : // Only display excerpts for 
   archives and  search. ?&gt;
      &lt;div class="entry-summary clearfix"&gt;
      &lt;?php if (ot_get_option('show_post_thumbnails') &amp;&amp; has_post_thumbn
      nil()){
          echo '&lt;div class="alignleft"&gt;';
          skeleton_thumbnailer('fourthree');
          echo '&lt;/div&gt;';
      }?&gt;
          &lt;?php the_excerpt(); ?&gt;
      &lt;/div&gt;&lt;!-- .entry-summary --&gt;
  
  &lt;?php else : ?&gt;
  
  &lt;div class="entry-content"&gt;
  &lt;?php
  if (ot_get_option('show_post_thumbnails') &amp;&amp; has_post_thumbnail()) {
      echo '&lt;div class="alignleft"&gt;';
      skeleton_thumbnailer('thumbnail');
      echo '&lt;/div&gt;';
  }?&gt;
      &lt;?php //the_content( __( 
      'Continue reading &lt;span class="meta-nav"&gt;&amp;rarr;&lt;/span&gt;', 'smpl' ) );
      do_action('skeleton_content');
      ?&gt;
      &lt;div class="clear"&gt;&lt;/div&gt;
      &lt;?php wp_link_pages( array( 'before' =&gt; '&lt;div class="page-link"&gt;' .
       __( 'Pages:', 'smpl' ), 'after' =&gt; '&lt;/div&gt;' ) ); ?&gt;
      &lt;/div&gt;&lt;!-- .entry-content --&gt;
  &lt;?php endif; ?&gt;
  &lt;/div&gt; &lt;!-- conditional div class --&gt;
  &lt;/div&gt;&lt;!-- #post-## --&gt;
  &lt;?php comments_template( '', true ); ?&gt;
  
  &lt;?php endwhile; // End the loop. Whew. ?&gt;
  
  &lt;?php /* Display navigation to next/previous pages when applicable */ ?&gt;
  &lt;?php if (  $wp_query-&gt;max_num_pages &gt; 1 ) {
      do_action('skeleton_page_navi');
  }?&gt;
  </code></pre>
  
  <p>So the Question:</p>
  
  <p>Is it possible, as the loop hasn't looped yet, and I need to conditionally add the div class based on the number of results from the loop? </p>