• Hello forum. I need a way to show all categories even if empty including the counts, but i want to hide the “(0)” from categories with no post.

    Here is the code im using to display the category list with counts now…

    [please read https://codex.www.ads-software.com/Forum_Welcome#Posting_Code for posting code]

    $subcats = wp_list_categories('taxonomy=ad_cat&orderby=name&order=asc&hierarchical=0&show_count=1&pad_counts=1&use_desc_for_title=0&hide_empty=0&depth=1&number='.get_option('cp_dir_sub_num').'&title_li=&echo=0&child_of='.$cat->cat_ID);
    
    // strip out the default wp title tag since the use_desc_for_title param doesn't seem to work in WP 2.9.2
    
    $subcats = preg_replace('/title=\"(.*?)\"/','',$subcats);
    
    // if you want to strip out the no categories text, just uncomment the line below
    
    $subcats = str_replace('<li>No categories</li>', '', $subcats);
    
    // print out all the subcats for the current parent cat
    
    echo $subcats;
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘wp_list_categories need to hide the zeros from count’ is closed to new replies.