tony spencer » Wordpress http://www.tonyspencer.com It's Just Links Sat, 19 Oct 2013 14:31:31 +0000 http://wordpress.org/?v=2.9.1 hourly 1 Empty Wordpress categories don’t show up in the sidebar navigation http://www.tonyspencer.com/2006/05/05/empty-wordpress-categories-dont-show-up-in-the-sidebar-navigation/ http://www.tonyspencer.com/2006/05/05/empty-wordpress-categories-dont-show-up-in-the-sidebar-navigation/#comments Fri, 05 May 2006 20:34:14 +0000 tony http://www.tonyspencer.com/2006/05/05/empty-wordpress-categories-dont-show-up-in-the-sidebar-navigation/ I’ve been playing with Wordpress this week for a new feature for my Raleigh, NC and ran into this issue. If a category doesn’t have any posts in it, it will not show up in the sidebar navigation. Even worse, if it is a parent category Wordpress will not show the children categories even if they aren’t empty. I dug into the source code and found that the function responsible for retrieving the category list is wp_list_cats() and by default most themes pass no parameters to it. However, it is capable of accepting a large range of settings including one to fix our problem.

In your sidebar.php file replace this:

<?php wp_list_cats(); ?>

with this:

<?php
	$settings = "hide_empty=0";
	wp_list_cats($settings);
?>

Now all of your categories will show up even if they don’t have any posts in them. Unfortunately clicking on those empty categories results in “Sorry, no posts matched your criteria.”. You can change this by adding a category.php and writing your own content for the scenario where the category is empty.

]]>
http://www.tonyspencer.com/2006/05/05/empty-wordpress-categories-dont-show-up-in-the-sidebar-navigation/feed/ 6