[resolved] How to show empty categories on the default category widget (8 posts)

  1. Info Man
    Posted 3 years ago #



    change this:
    $cat_args['title_li'] = '';
    wp_list_categories(apply_filters('widget_categories_args', $cat_args));

    to this:
    $cat_args['title_li'] = '';
    $cat_args['hide_empty'] = 0;
    wp_list_categories(apply_filters('widget_categories_args', $cat_args));

  2. No, do NOT do that. EVER.

    Editing any core file will cause you massive debilitating pain and suffering. If you need to modify something like that, use a filter, add an action, or just write your own function.

  3. Info Man
    Posted 3 years ago #

    how to do it then in a simple, efficient and secure way?

    maybe the wordpress folks should ad this as an option in the default widget? show/hide empty categories.

    I really need this

  4. Michael
    Part-Time Forum Moderator
    Posted 3 years ago #

    do not edit WordPress core templates.

    see this last line:
    apply_filters('widget_categories_args', $cat_args

    this points to the possibility to use a filter function to change the parameters;

    example code, to add to functions.php of the used theme:

    function show_empty_categories_links($args) {
    	$args['hide_empty'] = 0;
    	return $args;


  5. There are many plugins that provide category widgets. Rather than editing a core file, experiment with one of them.

    They may be able to provide the functionality you are looking for.


  6. Info Man
    Posted 3 years ago #

    thank you guys. i've undone the core template edits and added the code from alchymyth to the P2 themes functions.php (at the end).

    Works fine for me

  7. Info Man
    Posted 3 years ago #

    love your quick response

  8. Myself, I thank alchymyth. He's the more productive reply one. ;)

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.