Excluding categories...code, plugin, nothing works (4 posts)

  1. Ogadi FIelds
    Posted 5 years ago #

    Hi all...

    I recently upgraded to wordpress 3.1.1, and it seems that the ability to exclude categories from the homepage (by adding code to functions.php) doesnt work for me anymore. It worked in 3.1 (after using the plugin hotfix). The code i used is as follows:


    I have tried the Ultimate Category Excluder plugin, and that didnt work. I have tried deactivating all plugins and switching to the default theme, and that didnt work either...

    Any ideas?

    Thanks in advance.

  2. Michael
    Forum Moderator
    Posted 5 years ago #

    category__not_in would use an array of category ids - not a string with a list of negative ids


    function exclude_category($query) {
    if ( $query->is_home ) {
    $query->set('category__not_in', array(6, 9));
    return $query;
    add_filter('pre_get_posts', 'exclude_category');
  3. Ogadi FIelds
    Posted 5 years ago #

    Thanks for the reply!

    I just tried that, but it still didnt work. Any other ideas?

  4. Ogadi FIelds
    Posted 5 years ago #

    any help or idea of what the problem could be? I tried deactivating all the plugins and changing to the default theme again, cleared cache, etc, but no luck...like i said, it all worked just before i upgraded to 3.1.1

Topic Closed

This topic has been closed to new replies.

About this Topic