showing empty categories
-
Hi I am having trouble trying to show empty categories in a dropdown. I can currently only get categories that have a post assigned too it. Im sure its simple, but havaing some issues. I’ve tries adding hide_empty, but no luck, so I’m probably doing it wrong, is anyone able to advise please? Code looks like below:
$categories = get_categories(‘taxonomy=my_category’, array( ‘hide_empty’ => false, ‘parent’ => 0 ));
$select = “<select name=’locations’ id=’cat’ class=’postform’>n”;
$select.= “<option value=’-1′>Select category</option>n”;foreach($categories as $category){
if($category->count > 0){
$select.= “<option value='”.$category->name.”‘>”.$category->name.”</option>”;
}
}$select.= “</select>”;
echo $select;
Any help appreciated!
- The topic ‘showing empty categories’ is closed to new replies.