• Resolved ganghiss

    (@ganghiss)


    Hey folks,

    I have the post count displayed for the categories widget when displayed as a dropdown.

    add_filter('widget_categories_dropdown_args','show_empty_categories_links');
    function show_empty_categories_links($args) {
    	$args['hide_empty'] = 0;
    	return $args;
    }

    I would like to hide the (0) on empty categories only, using str_replace or similar. I would like to do this with a hook or something that I can add to functions.php. Any suggestions?

Viewing 2 replies - 1 through 2 (of 2 total)
  • the wp_dropdown_categories() function (which is called by the widget) applies a filter ‘wp_dropdown_cats’ to the output;

    example:

    add_filter('wp_dropdown_cats','wp_dropdonw_categories_strip_zero_count');
    function wp_dropdonw_categories_strip_zero_count($output) {
    $output = str_replace('(0)','',$output);
    return $output;
    }
    Thread Starter ganghiss

    (@ganghiss)

    And we have a winner. Thank you. I just couldn’t get the right bits worked up to get it to take care of this.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Hide post count only for empty categories in widget dropdown’ is closed to new replies.