Exclude Category from the Feed doesn't work in WordPress
WordPress version: 3.1
I need to exclude one category from Feed, so I add the following function to the functions.php file. However, it doesn't work. How to fix it?
function ExcludeCategory($query) {
if ($query->is_feed) {
$query->set('cat开发者_开发知识库','-1716');
}
return $query;
}
add_filter('pre_get_posts','ExcludeCategory');
this'll work:
$query->set( 'category__not_in', '-1716' );
seems to be a problem with or change in in 3.1:
http://themehybrid.com/support/topic/exclude-category-from-archive-with-pre_get_posts#post-56892
http://wordpress.org/support/topic/query_posts-no-longer-working-in-31
I am not sure if you are referring to the blog home page. If that's the case then you probably need to replace 'feed' with 'home'. Otherwise, the code seems fine.
Change your feed structure.
E.g.
/feed?cat=-1716">Entries (RSS)
You might need to change this in FeedBurner too.
精彩评论