I have a number of slugs and items in my custom category:
SLUG - number
video - 5 items
music - 5 items
[no-slug] - 5 items
empty - 0 items
blabla - 0 items
I want to list all non-empty slugs (otpionally with number of items next to them), like:
[ video (5) ] [ music (5) ] [ other (5) ]
(empty and blabla omitted)
Anyone knows how to do that?
All I know is how to get a slug for particular item:
<?php $slug = $terms[0]->slug; ?>
UPDATE
My taxonomy registration:
functions.php
register_taxonomy("op", array("portfolio"), array(
"hierarchical" => true,
"label" => "Categories",
"singular_label" => "Category",
"rewrite" => true,
));
page-portfolio.php
$taxonomy = "op";
function get_taxonomy_list_html($taxonomy) {
$term_links = array();
foreach(get_terms('Category') as $term) {
if (!empty($term->slug) && $term->count>0) {
$link = get_term_link($term,$taxonomy);
$term_links[] = "[ <a href='{$link}'>{$term->name}</a> ({$term->count}) ]";
}
}
return implode(' ',$term_links);
}
Displays nothing :(