Home / functions.php / Exclude categories
  • How to Exclude categories

    no thumbnail sorry: Exclude categories

    Adding this PHP code to your wordpress functions.php file will allow you to exclude categories from your RSS feeds. Make sure to use a minus before the category id.

    ( click code to copy )

    wordpress snippet : PHP

    <>
    function excludeCat($query)
    {
       if ($query->is_feed)
          {
           $query->set('cat','-49');
          }
       return $query;
    }
    add_filter('pre_get_posts','excludeCat');
    

    ( WordPress codex functions, hooks, in this snippet. )

    query, get_post, get_posts, add_filter, is_feed,