![]() |
|
||||||
|
|
Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
I have a Wordpress custom page template created listing all of my blog posts. What I am trying to do is display a blog page, which lists all posts with 10 per page, with navigation, and exclude category 12, category 20, and category 50 from the list.
For some reason, I cannot get it to exclude these categories. I have even tried to exclude just one category and it still won't. I am including the code that I am using for this page. If there is a better way to do this, I am open to it. What I am doing is showing the page title, the post title, an excerpt, and a read more link. Thanks for your help. Code: PHP Code:
|
|
#2
|
||||
|
||||
|
you need to pass that as part of your WP_query args
http://codex.wordpress.org/Class_Reference/WP_Query
__________________
Nick "Fred and/or George Weasley" Croft Designs by Nick the Geek @Nick_theGeek on Twitter Make web design easier, get FireBug for FireFox Want to learn more about Genesis? Check out my Genesis Explained Series |
|
#3
|
|||
|
|||
|
Can you elaborate a little more on how to pass that part of WP_query args?
|
|
#4
|
|||
|
|||
|
So I tweaked my code and moved the query_posts around.
PHP Code:
|
|
#5
|
||||
|
||||
|
you need to add the category argument to your list of $args. You do not need two WP_Query() instances. Just put your 'cat' => '-x' into the array for your $args.
You also are calling your query wrong. with new WP_Query() you don't use have_posts() you will need to use $wp_query->have_posts() because you are calling the value for that one instance.
__________________
Nick "Fred and/or George Weasley" Croft Designs by Nick the Geek @Nick_theGeek on Twitter Make web design easier, get FireBug for FireFox Want to learn more about Genesis? Check out my Genesis Explained Series |
|
#6
|
|||
|
|||
|
Nick, got it! Thanks so much for clarifying this.
Just so I understand this, could I also exclude individual posts using this query - while I'm also excluding certain categories at the same time? I know it probably makes more sense to put everything into a category and just exclude the category. What would be the best way to do this, concatenate the post id with the category? $args = array( 'post_type' => 'post', 'posts_per_page' => 40, 'cat' => '-12, -11, -10, -9, -8, -5, -3' , 'paged' => $paged ); |
|
#7
|
||||
|
||||
|
you should be able to do that but you cannot include and exclude posts at the same time.
__________________
Nick "Fred and/or George Weasley" Croft Designs by Nick the Geek @Nick_theGeek on Twitter Make web design easier, get FireBug for FireFox Want to learn more about Genesis? Check out my Genesis Explained Series |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| exclude blog page category | s2aebelt | General Discussion | 3 | 10-09-2009 11:23 AM |
| Exclude category from home page | violet | General Discussion | 9 | 03-04-2009 11:38 AM |
© Copyright 2012 Copyblogger Media LLC · StudioPress™ is a trademark of Copyblogger Media LLC
Privacy Policy | Refund Policy | Terms of Service | Affiliate Program | Contact Us