title: How to wrap my columns properly with div's?
body: <p>I have a following code to wrap my columns inside div's:</p>
  
  <pre><code>&lt;div id="blogwrapper"&gt;  
  &lt;div id="blogs"&gt;    
      &lt;?php //enable pagination on static pages and blog pages
  
      $col = 1; //Let's create first column
      /*Let's add pagination to post page and static page*/
      if ( get_query_var('paged') ) {
      $paged = get_query_var('paged');
      } elseif ( get_query_var('page') ) {
      $paged = get_query_var('page');
      } else {
      $paged = 1;
      }
  
  
  
  $args = array(
      /* Add whatever you need here - see http://codex.wordpress.org/Class_Reference/WP_Query */    
       'paged' =&gt; $paged,
  
  );
  $temp = $wp_query;
  $wp_query = null;
  $wp_query = new WP_Query($args);
  
  if($wp_query-&gt;have_posts()):?&gt;&lt;?php while ( $wp_query-&gt;have_posts() ) : $wp_query-&gt;the_post();?&gt;        
  
  &lt;?php if ($col == 1) echo '&lt;div class="row"&gt;';//If column 1 create first row ?&gt;
  &lt;?php if ($col == 2) echo '&lt;div class="row2"&gt;';//If column 2 create second row ?&gt;
  
      &lt;div &lt;?php post_class('col'.$col); ?&gt; id="post-&lt;?php the_ID(); ?&gt;"&gt;
      &lt;h3&gt;&lt;a href="&lt;?php the_permalink(); ?&gt;"&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/h3&gt;
          &lt;div class="entry"&gt; 
                  &lt;div class="featured_img"&gt;
                  &lt;?php the_post_thumbnail();
        echo '&lt;div class="featured_caption"&gt;' . get_post(get_post_thumbnail_id())-&gt;post_excerpt . '&lt;/div&gt;';?&gt;
       &lt;/div&gt;&lt;!--/featured_img--&gt;
          &lt;?php  // let's enable more link on pages...
          global $more;
          $more = 0;
          ?&gt;
              &lt;?php the_content(); ?&gt; 
              &lt;div class="clear"&gt;&lt;/div&gt;               
              &lt;div class="custom_fields"&gt;&lt;?php the_meta(); ?&gt;&lt;/div&gt;&lt;br/&gt;
              &lt;p class="postmetadata"&gt;
  
              &lt;?php _e('Filed under&amp;#58;','override'); ?&gt; &lt;?php the_category(', ') ?&gt; &lt;?php _e('by','override'); ?&gt; &lt;?php  the_author(); ?&gt;&lt;br/&gt;&lt;?php the_tags('Tags:', ', ', '&lt;br /&gt;'); ?&gt;
              &lt;?php _e('Posted on:&amp;nbsp;','override'); ?&gt;&lt;?php the_time('l, F jS, Y'); ?&gt;&lt;br/&gt;
  
              &lt;?php comments_popup_link('No Comments &amp;#187;', '1 Comment &amp;#187;', '% Comments &amp;#187;'); ?&gt; &lt;?php edit_post_link('Edit', ' &amp;#124; ', ''); ?&gt;
              &lt;/p&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;?php /*Enable Two Column Layout*/
          if($col==1) {
          $col=2;
          echo "&lt;/div&gt;";
          }
          else if($col==2)  {
          $col=1;
           echo "&lt;/div&gt;";
          }
  
      endwhile; ?&gt;
      &lt;div class="clear"&gt;&lt;/div&gt;
      &lt;div class="navigation"&gt;
  
      &lt;?php
      global $wp_query;
      $big = 999999999; // need an unlikely integer
  
      echo paginate_links( array(
      'base' =&gt; str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
      'format' =&gt; '?paged=%#%',
      'current' =&gt; max( 1, $paged ),
      'total' =&gt; $wp_query-&gt;max_num_pages
      ) );
      ?&gt;
  &lt;/div&gt;
  &lt;?php endif; ?&gt; 
  &lt;?php
  $wp_query = null;
  $wp_query = $temp;
  wp_reset_query();
  ?&gt;
  
  
  
  &lt;/div&gt;&lt;!--/blogs--&gt; 
  &lt;/div&gt;&lt;!--/blogswrapper--&gt;  
  </code></pre>
  
  <p>
  But here is the problem: I am getting a <b>bunch</b> of empty div's <b>(div class="row" and div class="row2")</b> in process (depending of my reading settings inside back end for example if my reading setting is <b>Blog pages show 7 posts </b>) output looks like this:<br/><a href="http://www.vasinternetposao.com/testall/wrap_problem.png" rel="nofollow noreferrer">http://www.vasinternetposao.com/testall/wrap_problem.png</a>.<br/> But if I set <b>Blog pages show 2 posts</b> I am getting <b>"only"</b> two empty div's.
  <br/><a href="http://www.vasinternetposao.com/testall/wrap2.png" rel="nofollow noreferrer">http://www.vasinternetposao.com/testall/wrap2.png</a>
  <br/>So does anyone know how to wrap my columns properly without all those <b>empty</b> div's? 
  THX!!</p>