Support » Fixing WordPress » Appearance->Widgets->Sidebar->Categories

  • Hi all,

    Have tried a few things seen in Google, but nothing has worked so far.

    If you install: Appearance->Widgets->Sidebar->Categories

    Now, on any PAGE or POST, I have a categories list on the right-side (Sidebar). I’m trying to HIDE one of those categories that’s being listed. The category ID number is 20 and I’ve tried some PHP code where you enter the category number you want to hide, but it didn’t work.

    To be clear. I have categories: Dogs, Cats, Horses, Birds. I want the category Horses to NOT BE DISPLAYED on the list.

    Thank you for any help you can provide.

    • This topic was modified 3 years, 2 months ago by Michael.
    • This topic was modified 3 years, 2 months ago by Michael.
Viewing 2 replies - 1 through 2 (of 2 total)
  • which codes exactly have you tried?

    this code seems to work (tested in Twenty Seventeen), when added into functions.php of your (child) theme:

    //Hide categories from WordPress default Categories widget
    function exclude_widget_default_categories($args){
        $exclude = "20";
        $args["exclude"] = $exclude;
        return $args;
    }
    add_filter("widget_categories_args","exclude_widget_default_categories");

    Thank you, Michael.

    I had not seen/found that code anywhere on Google while looking for a fix.

    It worked like a champ.

    Thank you for taking your time to provide an answer and solution.

    Take care,

    Michael

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Appearance->Widgets->Sidebar->Categories’ is closed to new replies.