Title: Exclude category posts
Last modified: August 20, 2016

---

# Exclude category posts

 *  [steve@skgraphicdesign.com](https://wordpress.org/support/users/steveskgraphicdesigncom/)
 * (@steveskgraphicdesigncom)
 * [14 years, 3 months ago](https://wordpress.org/support/topic/exclude-category-posts/)
 * Hi Everyone,
    I have done this before with success but seem to be missing something
   with this code. On the blog page, I want to show all posts except ID 3 and 5.
 * Here is the code:
 * <?php global $more; $more = 0; $paged = (get_query_var(‘paged’)) ? get_query_var(‘
   paged’) : 1; query_posts(“category_name=blog&paged=$paged&posts_per_page=10”);
   $count=1; while(have_posts()): the_post(); $mykey_values = get_post_custom_values(‘
   image’); ?>
 * Thanks for any help!
     Steve

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

 *  [Digital Raindrops](https://wordpress.org/support/users/adeptris/)
 * (@adeptris)
 * [14 years, 3 months ago](https://wordpress.org/support/topic/exclude-category-posts/#post-2592275)
 * Have a look at the second example from [Query Posts](http://codex.wordpress.org/Function_Reference/query_posts?#Examples)
 * HTH
 * David
 *  Thread Starter [steve@skgraphicdesign.com](https://wordpress.org/support/users/steveskgraphicdesigncom/)
 * (@steveskgraphicdesigncom)
 * [14 years, 3 months ago](https://wordpress.org/support/topic/exclude-category-posts/#post-2592278)
 * Hi David,
 * It makes sense but I having the issue of what actual info and where do I place
   it.
 * I know it will go in with this piece of code.
    query_posts(“category_name=blog&
   paged=$paged&posts_per_page=10”)
 * But that is where I am stumped.
 * Any ideas from your end?
 *  [Digital Raindrops](https://wordpress.org/support/users/adeptris/)
 * (@adeptris)
 * [14 years, 3 months ago](https://wordpress.org/support/topic/exclude-category-posts/#post-2592343)
 * Ok looking at your reply, do you want to exclude posts from a category, or as
   the title says exclude some categories from say the home page?
 *     ```
       <?php
       $args = array(
       	'cat' => '-1,-2,-3',
       	'posts_per_page' => 10,
       	'paged' => $paged,
       	'order'    => 'DESC'
       );
       query_posts( $args );
       ?>
       ```
   
 * This bit is confusing?
 * >  category_name=blog
 * HTH
 * David
 *  Thread Starter [steve@skgraphicdesign.com](https://wordpress.org/support/users/steveskgraphicdesigncom/)
 * (@steveskgraphicdesigncom)
 * [14 years, 3 months ago](https://wordpress.org/support/topic/exclude-category-posts/#post-2592355)
 * Hi David,
 * The two posts I have are located in the January archives
 * Here is the link for the site.
    [http://pediatricfamilydental.com/temp/?page_id=30](http://pediatricfamilydental.com/temp/?page_id=30)
 * I want exclude All Aboard and Our Stations from showing on the blog page itself.
   Is there a way to hide these from showing here?
 * These two posts are used on the home page which is fine but becasue they are 
   posts, they show under archives on the blog page.
 * Thanks
    Steve
 *  Thread Starter [steve@skgraphicdesign.com](https://wordpress.org/support/users/steveskgraphicdesigncom/)
 * (@steveskgraphicdesigncom)
 * [14 years, 3 months ago](https://wordpress.org/support/topic/exclude-category-posts/#post-2592356)
 * category_name=blog is basically saying to list all posts that fall under the 
   category Blog. The other two items that show have their own category name which
   makes it confusing of why they would show under archives.
 *  Thread Starter [steve@skgraphicdesign.com](https://wordpress.org/support/users/steveskgraphicdesigncom/)
 * (@steveskgraphicdesigncom)
 * [14 years, 3 months ago](https://wordpress.org/support/topic/exclude-category-posts/#post-2592382)
 * the more I dig into this it appears that the posts only appear as archive posts.
   Is there a way to hide on the blog page under archives?
 *  [Digital Raindrops](https://wordpress.org/support/users/adeptris/)
 * (@adeptris)
 * [14 years, 3 months ago](https://wordpress.org/support/topic/exclude-category-posts/#post-2592388)
 * It looks like you have fixed it by changing the post categories?
 * If it is resolved, please let us know the solution and mark the topic as resolved.
 * Regards
 * David
 *  Thread Starter [steve@skgraphicdesign.com](https://wordpress.org/support/users/steveskgraphicdesigncom/)
 * (@steveskgraphicdesigncom)
 * [14 years, 3 months ago](https://wordpress.org/support/topic/exclude-category-posts/#post-2592400)
 * No it is not fixed, I think I just figured out why it is not changing in my template
   files. It shows all posts associated with the category name “blog”. I think I
   need some type of “if statement”. If home then show the two posts otherwise if
   blog page do not show.

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

The topic ‘Exclude category posts’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 8 replies
 * 2 participants
 * Last reply from: [steve@skgraphicdesign.com](https://wordpress.org/support/users/steveskgraphicdesigncom/)
 * Last activity: [14 years, 3 months ago](https://wordpress.org/support/topic/exclude-category-posts/#post-2592400)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
