WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

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

Is there a way I can display all categories in the categories widget that comes with wordpress. I do not want to have to edit the core files and I want to stay away from rewriting the widget, but if need be I will. Is there anyway to hook into the widget just to get this functionality.

share|improve this question
up vote 2 down vote accepted

Not sure what you mean by 'display all categories', i thought it does that by default?

Anyways...you can hook into it, using the following filter hooks:

  • widget_categories_args
  • widget_categories_dropdown_args

Both hooks pass the query args to get the categories as an array.

The default is array('orderby' => 'name', 'show_count' => $c, 'hierarchical' => $h), wherein $c and $h are booleans and represent if the user selected 'Show post counts' and 'Show hierarchy' in the widget's options, respectively.

The dropdown version gets another value: $cat_args['show_option_none'] = __('Select Category');, setting the label for the 'none selected' state.

You'll can hook the same callback to both filters, so that the result is the same no matter if Show as dropdown is selected or not.

BTW: The widgets that come with WP out of the box are defined in wp-includes/default-widgets.php, the code in there is quite readable.

share|improve this answer

simple answer:

add_filter( 'widget_categories_args', 'mytheme_widget_cat_args' );
function mytheme_widget_cat_args($cat_args) {
    // the default for "hide_empty" = 1, so
    $cat_args['hide_empty'] = 0;
    // we can override any other defaults here too
    return $cat_args;
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.