Print list of Categories that contain Post
Description
This code will generate a list of categories that contain post. If a category does not have any post then it will not appear in the list.
This code will generate a list of categories that contain post. If a category does not have any post then it will not appear in the list.
CSS Source Code
/*******Sidebar Categories Start******/
.categories {
border: 1px solid;
display: table;
float: left;
}
.categories li, .categories li a {
color: #ffffff;
font-size: 20px;
}
.categories li {
border: 1px solid;
float: left;
list-style: none inside none;
width: 350px;
}
.categories li a {
float: none;
text-transform: uppercase;
width: auto;
}
/*******Sidebar Categories End******/
PHP Source Code
<?php wp_list_cats('sort_column=name&optioncount=1'); ?>
or
<?php wp_list_cats('child_of=2&sort_column=name&title_li=&hierarchical=1&depth=2&optioncount=1');?>
to exclude certain categories use this code:
<?php wp_list_cats('exclude=0&sort_column=name&optioncount=1'); ?>