Hide categories from WordPress category widget

Age of Article Warning:
This article was originally published 68 months ago. The information, tips and techniques explained may outdated. Examples shown on this page may no longer work. Please consider this when viewing the below content.


The WordPress category widget allows you to list your blog’s categories in the sidebar and sometimes the footer, depending on your theme’s footer settings.

This can be really useful for helping people to navigate your website. The biggest problem however is that many themes use a particular category, for eg a “portfolio” or a “slider” category for managing the posts to use as images in the slider or portfolio.

Depending on your website, you possibly don’t want people to end up on a page of images used in your slider. So you’d like to hide this category name from the listing of categories that are displayed in the sidebar widget.

How do you do this?

The default widget doesn’t have an option for this, so a quick and easy way is to add a quick function to your childtheme’s functions.php file and “exclude” the categories that you’d like to hide.

Add the following code into your functions.php file:

/* Remove category from category widget */
function dtwd_exclude_widget_category($args){
$exclude = "1,2,3"; // IDs of excluding categories
$args["exclude"] = $exclude;
return $args;

Be sure to replace the 1,2,3 with the actual categories that you’d like to exclude from the category list in the sidebar.


2 thoughts on “Hide categories from WordPress category widget”

  1. Hi David

    Thanks for this. I found the exact (?) same code on the WordPress.org support forum, but yours worked first time and theirs gave me the WSOD. Go figure. I’ll be adding this to my cheat sheet.


    • Hi Dom,

      yes it’s a simple function to add an array of ids to exclude, annoying that white screen when it happens.

Comments are closed.