Title: Exclude category from loop grid
Last modified: August 21, 2016

---

# Exclude category from loop grid

 *  Resolved [hockeyhero4](https://wordpress.org/support/users/hockeyhero4/)
 * (@hockeyhero4)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/exclude-category-from-loop-grid/)
 * Currently I am showing all recent posts on my homepage in a 2 column grid layout.
   It works just fine with this code:
 *     ```
       <div id="gridcontainer"> 
   
       <?php
       $counter = 1; //start counter
       $grids = 2; //Grids per row
       global $query_string; //Need this to make pagination work
       /*Setting up our custom query (In here we are setting it to show 12 posts per page and eliminate all sticky posts) */
       query_posts($query_string . '&caller_get_posts=1&posts_per_page=12');
   
       if(have_posts()) :	while(have_posts()) :  the_post();
       ?>
       <?php
       //Show the left hand side column
       if($counter == 1) :
       ?>
       			<div class="griditemleft">
                        <h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
       			    <div class="format_teaser entry-content"><p><?php the_excerpt(); ?></p></div>
                   </div>
       <?php
       //Show the right hand side column
       elseif($counter == $grids) :
       ?>
       <div class="griditemright">
                       <h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
       			    <div class="format_teaser entry-content"><p><?php the_excerpt(); ?></p></div>
                   </div>
       <div class="clear"></div>
       <?php
       $counter = 0;
       endif;
       ?>
       <?php
       $counter++;
       endwhile;
       //Pagination can go here if you want it.
       endif;
       ?>
       </div>
       ```
   
 * What I need to do is exclude category ID = 1.
 * Suggestions, please?

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [Caramboo](https://wordpress.org/support/users/caramboo/)
 * (@caramboo)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/exclude-category-from-loop-grid/#post-4200278)
 * Change:
 * `query_posts($query_string . '&caller_get_posts=1&posts_per_page=12');`
 * to
 * `query_posts($query_string . 'cat=-1&caller_get_posts=1&posts_per_page=12');`
 *  Thread Starter [hockeyhero4](https://wordpress.org/support/users/hockeyhero4/)
 * (@hockeyhero4)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/exclude-category-from-loop-grid/#post-4200458)
 * You’re awesome, thank you very much.
 *  Thread Starter [hockeyhero4](https://wordpress.org/support/users/hockeyhero4/)
 * (@hockeyhero4)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/exclude-category-from-loop-grid/#post-4200459)
 * Resolved.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Exclude category from loop grid’ is closed to new replies.

## Tags

 * [category](https://wordpress.org/support/topic-tag/category/)
 * [exclude](https://wordpress.org/support/topic-tag/exclude/)
 * [loop](https://wordpress.org/support/topic-tag/loop/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 2 participants
 * Last reply from: [hockeyhero4](https://wordpress.org/support/users/hockeyhero4/)
 * Last activity: [12 years, 7 months ago](https://wordpress.org/support/topic/exclude-category-from-loop-grid/#post-4200459)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
