Set div columns in a loop by post count

$post_count is a WP_Query variable. You need $the_query->post_count

if( $the_query->have_posts() ): ?> <h1>Partners<h1><hr> <?php 
  while( $the_query->have_posts() ) :
   $the_query->the_post();
    if($the_query->post_count=1){
       // ...

Otherwise it looks like it should work though I am not in a position to test this right now.

Leave a Comment