How to show empty categories in Wordpress using the default category widget
This is a hack, but a simple one. Surprisingly enough, Wordpress 2.3 doesn’t have an option in the default category widget to show empty categories. Personally I prefer to only show categories that have posts, but here’s a really simple way to do it.
If you are not using widgets, use this to call the list category function with the proper parameters in sidebar.php or whatever file you’re using to display the categories:
$args = “hide_empty=0″;
wp_list_cats($args);
If you are using widgets, it’s just as easy, open /includes/widgets.php and search for “$cat_args” (should be around line 627 or so). Change this line:
$cat_args = “orderby=name&show_count={$c}&hierarchical={$h}”;
to
$cat_args = “hide_empty=0&orderby=name&show_count={$c}&hierarchical={$h}”;
I’m sure there is a simple way to change the properties of the default category widget to allow you to set that parameter through the widget UI, but this works great and doesn’t cause any problem using widgets.
No related posts.
Related posts brought to you by Yet Another Related Posts Plugin.
Comments
Leave a comment Trackback