WordPress.org

Ready to get started?Download WordPress

Forums

Exclude category from feed but not on the cat feed (1 post)

  1. henri
    Member
    Posted 3 years ago #

    HI all do you know how I can exclude some cats from the main feed and still have a feed for the category excluded?

    Assuming category 7 is named "test"

    use this :

    // Exclude category from feed
    function myFilter($query) {
    	if ($query->is_feed) {
    		$query->set('category__not_in',array(7));
    
    	}
    return $query;
    }
    add_filter('pre_get_posts','myFilter');

    And still have http://mydomain.com/category/test/feed ?

    Thanks all

Topic Closed

This topic has been closed to new replies.

About this Topic