0

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 ) );
}

3 Answers 3

1

You'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.

2
0
$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.

1
  • 1
    Please explain why that could solve the problem.
    – fuxia
    Feb 19, 2013 at 16:52
0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.