Excluding Categories in WordPress Sidebar Widget

This is a short Youtube video demo on how you can exclude categories from you side bar if using the sidebar widget. This requires us to edit the widgets.php file instead of the sidebar.php file. More how to videos can be found at the Traffic is Gold Youtube channel.

Similar Videos:
Excluding Pages In The WordPress Sidebar

We also announce our videos on Twitter, you can follow us on Twitter here: @trafficisgold.

Step by Step code credit goes to Lance Hoff

Step 1:
Download widgets.php from here: wp-includes/widgets.php

Step 2:
Find this line of code:
$d = $options[$number][‘dropdown’] ? ‘1’ : ‘0’;

under it palce this line of code: $ex = “1,2,3”;
(NOTE: change out 1,2,3 with the actual Categories you want to exclude.)

So all together it looks like this:
$d = $options[$number][‘dropdown’] ? ‘1’ : ‘0’;
$ex = “1,2,3”;

Step 3:

$cat_args = array(‘orderby’ => ‘name’, ‘show_count’ => $c, ‘hierarchical’ => $h);

$cat_args = array(‘orderby’ => ‘name’, ‘show_count’ => $c, ‘hierarchical’ => $h, ‘exclude’ => $ex );

Step 4:
Save the file and uplaod back to it’s original location

You are done!!

Again thanks to Lance for the code and his step by step blog post. Please visit the site here.

About Josh


  1. Hello,

    Does this still work on the newer version of wordpress? I cant seem to find updated versions of this. Hope you could help. Thanks!


Speak Your Mind