WordPress Widget – Exclude some categories

I’ve often found a need for a simple replacement to the WordPress category widget that allows me to remove some of the categories. I whipped this up real quick for a client and thought others might find it handy. You can copy and paste it or download it from Google Code. Comment with any questions or suggestions.

 'Selective categories', 'description' => 'Show a list of Categories, with the ability to exclude categories' );
                $control_ops = array( 'id_base' => 'some-cats-widget' );
                $this->WP_Widget( 'some-cats-widget', 'Selective Catagories', $widget_ops, $control_ops );
        }

        function form ( $instance){
                $defaults = array( 'title' => 'Catagories', 'cats' => '' );
                $instance = wp_parse_args( (array) $instance, $defaults );
                ?>
                

"; wp_list_categories("exclude=$cats&title_li="); echo ""; echo $after_widget; } } function register_jorbin_widget(){ register_widget('limited_catagories_list_widget'); } add_action('widgets_init', 'register_jorbin_widget'); ?>

3 thoughts on “WordPress Widget – Exclude some categories”

    1. I’d recommend putting it either in your theme’s functions.php file, in a plugin, or in a file that you can upload to your mu-plugins folder (so you don’t have to worry about activating it).

Leave a Reply

Your email address will not be published. Required fields are marked *