Wordpress: force wp_tag_cloud to display empty categories?
I'm using wp_tag_cloud()
to display the categories in my custom taxonomy:
$args = array
(
'format' => 'list',
'orderby' => 'name',
'order' => 'ASC',
'topic_count_text_callback' => default_topic_count_text,
'link' 开发者_运维百科 => 'view',
'taxonomy' => 'my_tax',
'echo' => true
);
wp_tag_cloud( $args );
The problem is that only categories with posts are displayed, so instead of seeing 40+ categories I only see 3.
Is there a way to force wp_tag_cloud to display all categories?
Some spelunking in wp_tag_cloud()
(line 526 in wp-includes/category-template.php) shows that it calls get_terms()
(line 1114 in wp-includes/taxonomy.php) and passes through the $args array that was passed to wp_tag_cloud()
. get_terms()
has a param called hide_empty
that defaults to true
.
This is untested, but I think if you simply add "hide_empty" => false"
to your $args you'll get what you want. There may be other args to get_terms()
that are of interest to you.
精彩评论