我的自定义类别中有许多Slug和项目:
SLUG-编号
视频-5项
音乐-5项
[无子弹]-5项
空-0项
blabla-0项
我想列出所有非空的slug(每个slug旁边都有项目数),比如:
[视频(5)][音乐(5)][其他(5)]
(空和blabla省略)
有人知道怎么做吗?
我所知道的就是如何获得特定项目的slug:
<?php $slug = $terms[0]->slug; ?>
更新我的分类法注册:功能。php
register_taxonomy("op", array("portfolio"), array(
"hierarchical" => true,
"label" => "Categories",
"singular_label" => "Category",
"rewrite" => true,
));
页面组合。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);
}
不显示任何内容:(