ThemeShaper Forums » Thematic


how to change the tag cloud tooltip?

(4 posts)
  • Started 10 years ago by mlujan
  • Latest reply from helgatheviking
  • This topic is resolved
  1. Hi folks,

    Trying to design a Thematic child theme for my photoblog. How does one go about changing the tooltip one sees when moving the mouse over an item in the tag cloud? I would like it to say "pictures" rather than "topics."

    Thanks in advance for your assistance!

    Posted 10 years ago #
  2. this is not a thematic question, but I managed to track down the answer. digging around in wordpress' includes folder, i first looked at default-widgets.php which defines the default WP_Widget_Tag_Cloud function.

    in that function you'll see:

    wp_tag_cloud( apply_filters('widget_tag_cloud_args', array('taxonomy' => $current_taxonomy) ) );

    bam a filter! ok so what parameters does wp_tag_cloud accept?

    topic_count_text_callback looks promising

    so we can filter in a new callback... except we don't know what that callback should look like. i did a search across all of the wp-includes folder to find the original function default_topic_count_text which turns out to be in the category-template.php file.

    so i copied the whole thing into my functions.php and renamed it.

    here is the full thing. tested and working for me.

    //point tag cloud to use our callback
    function tag_cloud_args($args) {
       $my_args = array(
    	'topic_count_text_callback' => 'my_tag_text_callback',
       return wp_parse_args( $my_args, $args );
    add_filter('widget_tag_cloud_args', 'tag_cloud_args');
    //here is the original callback, renamed and with topics changed to pictures
    function my_tag_text_callback( $count ) {
       return sprintf( _n('%s picture', '%s pictures', $count), number_format_i18n( $count ) );

    you just inspired me to make my first contribution to the Codex. whoa! geek alert!

    Posted 10 years ago #
  3. Ms Viking, you are a godsend! (Or Odinsend, if you prefer :)) Thank you immensely. Sorry for the OT question, and congratulations on your first Codex contribution!

    Posted 10 years ago #
  4. was an interesting distraction. don't forget to mark as resolved.

    Posted 10 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.