Title: Excluding Posts (again!)
Last modified: August 21, 2016

---

# Excluding Posts (again!)

 *  Resolved [AdamJWL](https://wordpress.org/support/users/adamjwl/)
 * (@adamjwl)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/excluding-posts-again/)
 * I have scoured the posts already available but I still can’t seem to get it. 
   I bet some of you are fed up of seeing the same old stuff!
 * Im running a travel website, [http://www.travelvows.com](http://www.travelvows.com).
   I have a page for reviews, a page for guides, and now I have just created a new
   page for a personal blog part. Im creating a new template (identical to the one
   I am using under ‘Guides’).
 * On my dashboard, a ‘Post’ goes onto my ‘guides’ page, and ‘Reviews’ goes onto
   my ‘Reviews’ page. I am attempting for the ‘Post’ category ‘Blog’ to appear solely
   on my ‘Blog’ page, and not on my ‘Guides’ page.
 * If you haven’t glossed over yet, we’ll talk about code.
 *     ```
       <?php
   
       /*
   
       Template Name: Blog
   
       */
   
       ?>
   
       <?php get_header(); global $colabs_options; ?>
   
       <div id="stories-map"class="map-destinations columns col11"></div><!-- .map-destinations -->
   
       <?php  echo setMap( array(
   
       	'el' => 'stories-map', 
   
       	'posttype' => 'post'
   
       	)
   
       );  ?>	 
   
       <div class="main columns col11">
   
       	<div class="col-stories columns col11 fl">
   
               <h2 class="ribbon"><?php _e('Blog','colabsthemes');?></h2>
   
       		<?php $query_posts = new WP_query('post_type=post&paged='.$paged);?>
   
       		<?php if($query_posts->have_posts()):?>
   
               <ul class="post-list">
   
       			<?php while ( $query_posts->have_posts() ) : $query_posts->the_post(); ?>
   
                       <li class="posting">
   
       					<?php colabs_image(array());?> 
   
       					<h3><a href="<?php the_permalink();?>"><?php the_title();?></a></h3>
   
       					<span class="bigred"><?php the_category(' ,');?><?php the_tags(' // ', ', ', '');?></span>				
   
       					<br/><?php colabs_custom_excerpt();?>
   
       					<div class="more"><a href="<?php the_permalink();?>"><?php _e('read more','colabsthemes');?></a></div>
   
       				</li>
   
                   <?php endwhile; ?>
   
       		</ul>
   
       		<?php colabs_pagination('', $query_posts);?><!-- .pagination -->
   
       		<?php endif;?>		
   
           </div>
   
           <?php //get_sidebar();?>
   
       </div>
   
       <?php get_footer(); ?>
       ```
   
 * The above code is for my new template, which I wish to exclude all categories
   apart from the **ID=2** (blog). I have seen some examples and tutorials online
   but I am not sure where to put the extra code get_post.
 *     ```
       <?php
   
       /*
   
       Template Name: Stories
   
       */
   
       ?>
   
       <?php get_header(); global $colabs_options; ?>
   
       <div id="stories-map"class="map-destinations columns col11"></div><!-- .map-destinations -->
   
       <?php  echo setMap( array(
   
       	'el' => 'stories-map', 
   
       	'posttype' => 'post'
   
       	)
   
       );  ?>	 
   
       <div class="main columns col11">
   
       	<div class="col-stories columns col11 fl">
   
               <h2 class="ribbon"><?php _e('Guides','colabsthemes');?></h2>
   
       		<?php $query_posts = new WP_query('post_type=post&paged='.$paged);?>
   
       		<?php if($query_posts->have_posts()):?>
   
               <ul class="post-list">
   
       			<?php while ( $query_posts->have_posts() ) : $query_posts->the_post(); ?>
   
                       <li class="posting">
   
       					<?php colabs_image(array());?> 
   
       					<h3><a href="<?php the_permalink();?>"><?php the_title();?></a></h3>
   
       					<span class="bigred"><?php the_category(' ,');?><?php the_tags(' // ', ', ', '');?></span>				
   
       					<br/><?php colabs_custom_excerpt();?>
   
       					<div class="more"><a href="<?php the_permalink();?>"><?php _e('read more','colabsthemes');?></a></div>
   
       				</li>
   
                   <?php endwhile; ?>
   
       		</ul>
   
       		<?php colabs_pagination('', $query_posts);?><!-- .pagination -->
   
       		<?php endif;?>		
   
           </div>
   
           <?php //get_sidebar();?>
   
       </div>
   
       <?php get_footer(); ?>
       ```
   
 * This is the code I wish to excluse JUST ID=2 (blog) and allow all others to go
   through.
 * If anyone could help me and allow me to sort this problem I would be greatly 
   appreciative.
 * Thanks for reading!
 * Adam

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

 *  [nathan_dawson](https://wordpress.org/support/users/nathan_dawson/)
 * (@nathan_dawson)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/excluding-posts-again/#post-4302718)
 * In the first set of code change
    `<?php $query_posts = new WP_query('post_type
   =post&paged='.$paged);?>`
 * to
    `<?php $query_posts = new WP_Query('post_type=post&cat=2paged=' . $paged);?
   >`
 * Alternatively
 *     ```
       <?php $query_posts = new WP_Query( array(
         'post_type' => 'post',
         'paged'       => $paged,
         'cat'            => 2
       ) );
       ```
   
 * Do the same for the second block of code but change ‘cat’ from 2 to -2
 *  Thread Starter [AdamJWL](https://wordpress.org/support/users/adamjwl/)
 * (@adamjwl)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/excluding-posts-again/#post-4302721)
 * Thanks for the reply,
 * It’s probably me doing it wrong, but your first suggestion
 * – eliminates all posts from the ‘Blog’ page, and fails to eliminate any from 
   the ‘Guides page’
 * The second suggestion;
 * – leaves me with a completely white screen.
 * Do you know what I am doing wrong?
 *  Thread Starter [AdamJWL](https://wordpress.org/support/users/adamjwl/)
 * (@adamjwl)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/excluding-posts-again/#post-4302722)
 * Just checking, I have the correct ID, yes? The URL for the ‘blog’ category is
 * edit&taxonomy=category&tag_ID=2&post_type=post
 * I am assuming ID=2 means 2.
 *  Thread Starter [AdamJWL](https://wordpress.org/support/users/adamjwl/)
 * (@adamjwl)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/excluding-posts-again/#post-4302726)
 * Solved, thank you so much Nathan,
 * My ID was 2&.
 * Very much appreciated!

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

The topic ‘Excluding Posts (again!)’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 4 replies
 * 2 participants
 * Last reply from: [AdamJWL](https://wordpress.org/support/users/adamjwl/)
 * Last activity: [12 years, 6 months ago](https://wordpress.org/support/topic/excluding-posts-again/#post-4302726)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
