How to Exclude Category from Sidebar Widgets – WordPress

Have you work with WordPress Category widget? And found out that you can’t exclude other category from display? Excluding other category is useful if you don’t want the users or site viewers to see the specific or list of category. Today I will share you a very simple solution how you can easily exclude categories from sidebar widget.


Copy and paste this snippet into your functions.php of your current theme, if you don’t have one please create and paste this snippet.

Don’t want to get your hand dirty?

As always I will provide plugin it there’s any :), visit to download the plugin and see lots of built-in functionalities.

That’s it, if you have some suggestions or solutions please share it by commenting below.

by Ryan Sutana

  • Is there a way to modify this code to exclude tag by ID from a specific widget?

    • Untested code but I think this is a good to start

      // check what’s widget that is active
      if ( is_active_sidebar( ‘primary’ ) ) { //code here, exclude tag ID from this widget }

      Hope that helps

      • The widget is not in the sidebar. The template I’m using uses widgets to form the blocks of the main body (besides those of the sidebar).

        • Okay got it, but I think there’s no way we can add condition without actually going on to the code and add stuff.

          Or I think the code itself I mean update the widget code itself.

          • I do have access to the widget’s code if that’s what you mean. I just don’t know the syntax of the condition I want to add.