Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Exclude category from blog, but not WP Coda Slider WordPress


Hi again all!

I was using the WP Coda Slider plugin to display posts with the category 'testimonial', however I didn't want the testimonial category to be displayed on the blog page.

So, I decided to use the Simply Exclude plugin ( to exclude the testimonial category from the blog page, but now that I'm using the template tag for WP Coda Slider (which fixed a jquery issue), Simply Exclude is blocking the 'testimonial' category from the slider also. (see, it's just pulling in one blog post instead of the 'testimonial' category).

So, Simply Exclude is not doing the job. Is there some way I can exclude a category from the blog page, whilst keeping that category it in WP Coda Slider?

Many Thanks,

Answers (4)


Rashad Aliyev answers:

Yes you can do it via special query.

For example. Use like this query for your blog. Write your category id there (cat=-1) It will exclude the category from your blog query. Showposts =numer of your posts in the category

paged=your paggination.

<?php query_posts("cat=-1&showposts=10&paged=$paged");?>
<?php while (have_posts()) : the_post(); ?>

Rashad Aliyev comments:

PS: don't forget to disable your Simply Exclude plugin. ;)

folette comments:

This works well Rashad! But will it return the correct post count? Or is it just hiding the posts from view?

Rashad Aliyev comments:

I'm glad to hear it from you.

Let's look the code again. Think that your testimonial id is 5. We want to disable this code from your blog template.

As you made we should open blog template and make query as below.

Two important things: show posts and get pagging. Our example will show latest 10 post on your blog via (showposts=10) and also will exclude the category id 5 (which was our testimonial in example) and also "paged" will active it after 10 post.

<?php query_posts("cat=-5&showposts=10&paged=$paged");?>

Do you've any questions?


Jens Filipsson answers:

In your index.php file in your theme directory, add the following code:

<?php query_posts($query_string . '&cat=-3'); ?>

before this:

<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

Change -3 to the category ID you want to exclude.

<strong>edit: here's how to find the id of a category:</strong>

[[LINK href=""]][[/LINK]]


Oleg Butuzov answers:

add this to your functions.php
if (!is_admin()){
function parse_query_custom($wp_query){
$wp_query->query_vars['category__not_in'] = array(1,2,3);
return $wp_query;

// 1,2,3 is term ids of category with you should place there

Oleg Butuzov comments:

best solution that two above. thats two make filter just for the final loop, meanwhile mine will parse data and give you a correct results number (including paging)

Oleg Butuzov comments:

best solution that two above. thats two make filter just for the final loop, meanwhile mine will parse data and give you a correct results number (including paging)

folette comments:

Hi Oleg, I definitely appreciate that your solution returns the correct results, but unfortunately it doesn't work. Am I meant to be adding the categories I want to keep to the array? or the one I want to hide?

either way, WP Coda Slider just disappears :( any idea as to why this may be?


S├ębastien | French WordpressDesigner answers:

you must to disable your Simply Exclude plugin

in the file page.php you can paste this code :

if (is_page('blog'))
$paged = (get_query_var('page')) ? get_query_var('page') : 1;
$args = array (
'cat'=> -42,
'showposts' => 10,
'paged' => $paged


before this line
<?php while (have_posts()) : the_post(); ?>
you must replace 42 by the id of testimonials

if (is_page('blog')) means that posts of category "testimonials" are excluded only if we are in the page "blog".
If you want you can exclude this posts too a page "projects". To do that replace
if (is_page('blog'))
if ((is_page('blog'))OR(is_page('projects')))

So, tell me if that work fine