Age of Article Warning:
This article was originally published 37 months ago. The tips and techniques explained may be outdated, or information may longer be applicable. Please consider this when viewing the below content.

hide-blog-categories

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;
}
add_filter("widget_categories_args","dtwd_exclude_widget_category");

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.

hide-blog-categories-in-sidebar-widget

Hide categories from WordPress category widget was last modified: September 6th, 2016 by David Tiong
Hide categories from WordPress category widget