[wp-testers] Category Exclusion and 2.7-almost-beta

Christopher Weddell christopherweddell at googlemail.com
Sat Oct 18 21:53:46 GMT 2008


Long time viewer - first time poster...

Recently I have been wanting to exclude posts in certain categories
from everywhere but admin and single views - so I added this to
functions.php

// Hide category 5 from site (except admin, and single views)

add_action('pre_get_posts', 'remove_sold_cat' );

function remove_sold_cat() {
  global $wp_query;
if (is_admin() || is_single() ) {
} else {
	$wp_query->query_vars['cat'] = '-5';
}
}

I did not work as expected in 2.6 (posts in more than one category ie
1 & 5 would still appear in category archives for cat 1 listings) -
cry for help here: http://wordpress.org/support/topic/209915

So I thought I would try 2.7-almost-beta...
Category archives now look totally screwed as while cat 5 posts are
hidden in the category archive for cat 1 I am getting cat 1, 2, 3 and
4 posts showing - in fact whatever category archive I look at I get
posts from all categories appearing (except for cat 5 - which is
better than with 2.6!).  Plus when I look at the category archive for
cat 5 I don't see posts from cat 5 but I do see posts from cat 1, 2,
3, and 4.

Clean & fresh install of 2.7-almost-beta, no plugins installed and the
same things happen if using default or classic theme.

Any thoughts?
Cheers
Christopher


More information about the wp-testers mailing list