WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

how to edit wp category widget, so it would not show one of specified category? For example, it shows all categories in list, and I need to remove category Books, from it, how can I do it? Best regards, Y2ok

share|improve this question
up vote 0 down vote accepted
// This alters the get get_terms() arguments and hides some categories
function widget_category_excluder($args){
    // Replace the numbers with category IDs you need hidden
    $args['exclude'] = $args['exclude'].',1,2,3,'; // Keep it safe!
    // Or use exclude_tree to exclude children categories also
    // $args['exclude'] = $args['exclude'].',1,2,3,'; // Keep it safe!
    // (,1,2,3, is enclosed in ',' to ensure digits don't get welded)
    // Test and see what fits your needs best
    return $args;
// This allows hooking into WP_Widget_Categories and excluding Terms
add_filter('widget_categories_dropdown_args', 'widget_category_excluder');
add_filter('widget_categories_args', 'widget_category_excluder');

Add this code to your functions.php and experiment. It's a quick fix. A better alternative is a custom widget with the possibility to hide categories.


share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.