admin管理员组文章数量:1323342
I thought this would have displayed the post counts right next to the clickable links
wp_tag_cloud(
array( 'taxonomy' => $taxonomy,
'format' => 'list',
'smallest' => 12,
'largest' => 12,
'number' => 10000 ,
'separator' => '<li>' ,
'topic_count_text_callback'=> 'default_topic_count_text' )
);
but, it ends up displaying this;
item 1
item 2
item 3
What's the trick to make it display something like this?
item 1 (100)
item 2 ( 90 )
item 3 (15 )
I tried the following codex code, but that caused no visible change.
wp_tag_cloud( array( 'topic_count_text_callback' => 'my_tag_text_callback' ) );
function my_tag_text_callback( $count ) {
return sprintf( _n('%s picture', '%s pictures', $count), number_format_i18n( $count ) );
}
I thought this would have displayed the post counts right next to the clickable links
wp_tag_cloud(
array( 'taxonomy' => $taxonomy,
'format' => 'list',
'smallest' => 12,
'largest' => 12,
'number' => 10000 ,
'separator' => '<li>' ,
'topic_count_text_callback'=> 'default_topic_count_text' )
);
but, it ends up displaying this;
item 1
item 2
item 3
What's the trick to make it display something like this?
item 1 (100)
item 2 ( 90 )
item 3 (15 )
I tried the following codex code, but that caused no visible change.
wp_tag_cloud( array( 'topic_count_text_callback' => 'my_tag_text_callback' ) );
function my_tag_text_callback( $count ) {
return sprintf( _n('%s picture', '%s pictures', $count), number_format_i18n( $count ) );
}
Share
Improve this question
asked Jun 11, 2012 at 10:00
Average JoeAverage Joe
1,8894 gold badges24 silver badges41 bronze badges
3 Answers
Reset to default 1You'll have to use the get_terms
function to build your own list if you want the count in there.
If we read the details of topic_count_text_callback
we can see why it may appear to not be working:
topic_count_text_callback
(string) (optional) The function, which, given the count of the posts with that tag, returns a text for the tooltip of the tag link. Default: default_topic_count_text
this function sets the link's title
attribute text, it doesn't show the count with the term directly in the text. If you hover over the links you'll see the text pop-up in a tooltip next to your cursor.
$tax_list = wp_list_categories( array( 'taxonomy' => 'YOUR-CUSTOM-TAXONOMY', 'orderby' => 'name', 'show_count' => 1, 'pad_counts' => 0, 'hierarchical' => 1, 'echo' => 0 ) );
Echo $tax_list that to the browser and you're done.
I'm a bit late. You can use "show_count" => 1
as args in wp_tag_cloud
and you will see your term count against its name. :-) Enjoy
本文标签: tagsDisplaying the post count of all custom taxonomy terms in a list format
版权声明:本文标题:tags - Displaying the post count of all custom taxonomy terms in a list format 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742135194a2422338.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论