I recently received a support ticket from someone who wished to exclude specific categories from the default WordPress category widget without using a plugin. In this tutorial, I will show you How to exclude categories from the WordPress category widget without a plugin
Exclude categories from the WordPress category widget – Step One:
The first thing we will need to do is determine the category ID. You can install a plugin which will reveal all IDs (and then delete the plugin after you’ve identified the ID). Or, you can do it without a plugin. Go to Dashboard > Categories > All Categories > hover over the edit button of the category you wish to exclude; in your browser’s admin bar, you will see a stream of text; make a note of the category ID:

Exclude categories from the WordPress category widget – Step Two:
Navigate to your functions.php file (Dashboard > Appearance > Editor > functions.php), and add this to the bottom of the file:
That will remove the category from the widget if you’re not using the drop-down option.
Exclude categories from the WordPress category widget – Step Three
If you’re using the drop-down option, you’ll need to add additional code. Add this to your functions.php file (adjusting the code to reflect the category ID you wish to exclude – you can exclude multiple categories by adding your category ID, divided by a comma:
Here’s a screenshot showing how it looks added to the functions.php file on my site.
Here’s the “before” and “after”:
Thanks for Davinder Singh of BasicWP for providing this code.
If you’re using a theme built on the Genesis Framework, and are interested in having me implement this for you, send me a note!
Did you know I offer a theme setup service? Get your Genesis WordPress theme installed and set up like the demo in under 24 hours. Learn more here.
Leave a Reply