How can you change the font-size range in the tag cloud via functions.php?

Community Forums Forums Design Tips and Tricks How can you change the font-size range in the tag cloud via functions.php?

This topic is: resolved

This topic contains 6 replies, has 3 voices, and was last updated by  Chris Moore 3 months, 4 weeks ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #32591

    Chris Moore
    Participant
    Post count: 135

    Hello,

    I tried changing the font-size in the tag cloud widget for the eleven40 child theme to no avail. It turns out that when you use the WordPress tag cloud widget you cannot alter the font-size via CSS. I don’t want to use yet another plugin my friends, so would someone be so kind as to give me the exact php function and code snippet that I could use in my eleven40 child theme’s functions.php file so that I can make the tag cloud font-size range go from 8pt up to 10pt (instead of up to 22pt, which is what it is right now).

    Thanks!

    ~ Chris


    Resepctfully, Chris Moore
    Web Dev, CSS Hacks, & Biz Consulting @ MooreCreativeIdeas.com / Blogging @ ReflectOnThis.com

    #32599

    Chris Moore
    Participant
    Post count: 135

    Solution City! I figured it out from this short tutorial here: http://chris.dziemborowicz.com/blog/2009/06/11/change-the-tag-cloud-font-size-in-wordpress-2-8/

    I just used the short code snippet he shared and placed it in my child theme’s functions.php. I ignored the suggestion of making it into a plugin.

    Here’s the code snippet I used in my child theme’s functions.php:

    function tcr_tag_cloud_filter($args = array()) {
    $args['smallest'] = 8;
    $args['largest'] = 12;
    $args['unit'] = 'pt';
    return $args;
    }

    Followed by:

    add_filter('widget_tag_cloud_args', 'tcr_tag_cloud_filter', 90);

    Anything I need to lookout for or be aware of? Is there a “better” way to do this?

    Thanks everyone!

    ~ Chris M.


    Resepctfully, Chris Moore
    Web Dev, CSS Hacks, & Biz Consulting @ MooreCreativeIdeas.com / Blogging @ ReflectOnThis.com

    #32600

    Chris Moore
    Participant
    Post count: 135

    Here’s an even shorter and “cleaner” way to do it (sharing for those who might find this thread):

    http://wordpress.org/support/topic/different-font-sizes-for-tag-clouds#post-2948370

    Here’s what I ended up using for my purposes (I wanted it to be 8pt – 11pt in size):

    add_filter('widget_tag_cloud_args','set_tag_cloud_sizes');
    function set_tag_cloud_sizes($args) {
    $args = array('smallest' => 8, 'largest' => 11);
    return $args;
    }


    Resepctfully, Chris Moore
    Web Dev, CSS Hacks, & Biz Consulting @ MooreCreativeIdeas.com / Blogging @ ReflectOnThis.com

    #65090

    bello-via
    Participant
    Post count: 5

    Very helpful. Thanks for updating the post with the code you used. Worked perfectly!

    #65091

    Chris Moore
    Participant
    Post count: 135

    Hello @bello-via,

    That’s great! So glad it worked out for you. I can’t count the number of times I have posted a question (here and elsewhere), only to just figure it out myself and post the answer. LOL…

    Have a great day!


    Resepctfully, Chris Moore
    Web Dev, CSS Hacks, & Biz Consulting @ MooreCreativeIdeas.com / Blogging @ ReflectOnThis.com

    #80237

    Mealtog
    Participant
    Post count: 352

    Nice, just got this to work Chris. Is there a way to add the number of tag items in () beside each tag?

    #80306

    Chris Moore
    Participant
    Post count: 135

    Thanks @mealtog! Unfortunately, I don’t have something ready-made for that. However, this may help you in your quest: http://dmblog.com/wordpress-tag-cloud-with-post-counts/


    Resepctfully, Chris Moore
    Web Dev, CSS Hacks, & Biz Consulting @ MooreCreativeIdeas.com / Blogging @ ReflectOnThis.com

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.