Support » Fixing WordPress » Change title attribute in tagcloud links

  • Hi,

    I want to edit the title attribute in the tagcloud links that now shows the count of post inside each tag (“x topics”).

    <a href="URL" class="tag-link-39" title="2 topics">Bangladesh</a>

    I’ve found some people in Google who offer this BAD solution:

    http://wordpress.org/support/topic/tag-cloud-edit-title?replies=5

    But I don’t want modify the category-template.php file, I think there will be another way to fix this with a plugin or functions.php code.

    Thank you so much : )

Viewing 3 replies - 1 through 3 (of 3 total)
  • The example for functions.php that customising TC widget

    // prepare a topic count text
    function my_default_topic_count_text( $count ) {
        return sprintf( _n('%s article', '%s articles', $count), number_format_i18n( $count ) );
    }
    // customise the tag cloud widget
    function my_tag_cloud_args($in){
        return 'topic_count_text_callback=my_default_topic_count_text';
    }
    add_filter('widget_tag_cloud_args', 'my_tag_cloud_args' );

    you can edit other parameters of the tag cloud widget according to codex. e.g.
    'smallest=8&largest=20&number=35&topic_count_text_callback=my_default_topic_count_text';

    for customising hardcoded wp_tag_cloud you need only to call your custom function for topic_count_text_callback in arguments. (do not use filter for widget_tag_cloud_args)

    Thread Starter Christian Rodríguez

    (@hanschristian)

    Thank you so much, Vjpo.

    I’m trying to understand and doing tests in my site with your code solution, but I don’t have enough php skills (I’m designer) to understand you or the Codex solution 🙁

    I’ve added the first code block to my functions.php but I don’t know how use these parameters to customize the title.

    Can you or anyone reading us be more specific? Thank you already for helping, Vjpo! : )

    Hi Hans! If you will clarify what text must be instead “x topics” and what kind of tag cloud do you use (default Tag Cloud widget or function wp_tag_cloud in theme code), I perhaps will be able to modify this function.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Change title attribute in tagcloud links’ is closed to new replies.