Oct
27
2008

Modifying the WordPress Tag Cloud Widget Font Size

by   |  Posted in Tutorials  |  18 comments

Using WordPress widgets for your sidebar really makes things easy on programmers and especially on users. The only problem I have come across is customizing the widgets so that they work exactly how you need and look the best for your specific design.

I needed to manipulate the Tag Cloud widget so that the size of the largest font was not too big. It only took going in and changing one line in the widgets.php files. I wouldn’t suggest doing this unless you are somewhat comfortable with messing around with your code.

File to manipulate: wp-includes/widgets.php

Find:

wp_tag_cloud(); // at around line 1372

Change to:

wp_tag_cloud('smallest=10&largest=14&number=25&orderby=name');

“smallest” is the size of the smallest font you want
“largest” is the size of the largest font you want
“number” is the amount of tags you want to appear
“orderby” is how the orders of the tags will be shown

About the author:

A freelance web developer living in Montreal who spends most of his time writing for this site and building Premium themes for WordPress. You can find him on Twitter @bavotasan.

Site5 Affiliate Link
If you liked this, please share it.

Tags: , , , , , , , , , , , , , ,

Short URL: http://bit.ly/d7W6QA

Discussion 18 Comments

  1. Stefano Z. on December 18, 2008 at 9:54 am

    Oh yeah. After hours spent around to find a clue to resize the font of the tag cloud, finally an answer!
    Let me say: THE answer!

    Bookmarked your website ;)
    Thanks

  2. Warren on February 24, 2009 at 8:03 pm

    Thanks a million. I read there was no way to change the number of tags nor the size of them. I am very grateful that you shared this solution. Namaste.

  3. oes tsetnoc on September 18, 2009 at 8:23 am

    Finally I have found this to modify my tag cloud! thanks again man!

  4. MissSillY on November 29, 2009 at 2:25 pm

    Very usefull!! Thanks! Does anybody know how and where to change the Font of an Widget? For example in the Tag Cloud?

  5. Klaus on December 18, 2009 at 5:49 am

    Better would be to place the following in the functions.php

    add_filter( ‘widget_tag_cloud_args’, my_tag_cloud_args );
    function my_tag_cloud_args($in){
    return ‘smallest=11&largest=11&number=25&orderby=name&unit=px’;
    }

    • Koss on January 14, 2010 at 7:30 am

      Thanks! This is best way!

  6. mv on January 17, 2010 at 7:42 am

    Grazie!

  7. Katy on March 23, 2010 at 4:28 pm

    Thanks so much, this is exactly what I was looking for!

  8. Sarah on April 15, 2010 at 1:37 am

    Thanks Klaus

    I was looking for something theme specific and add_filter is perfect.

  9. leo on May 17, 2010 at 11:48 am

    i cant see it under that file.

    any idea?

    • shulato on May 28, 2010 at 8:12 am

      yes, don’t see it also. why is that all font size are all the same? i already specify the smallest and largest size.

    • shulato on May 29, 2010 at 4:23 am

      my problem solved. the problem is the post tag count. :)

  10. Realchennai on October 1, 2010 at 1:27 pm

    Thanks for sharing Bavota!
    Is it possible to get define a some functions using add_filter or add_action from functions.php file in theme directory , instead of editing widgets.php?
    Thanks in advance

    • c.bavota on October 4, 2010 at 7:54 pm

      I know there are some plugins out there that do this, so they probably have the code you would need to figure this one out.

  11. Luke on October 7, 2010 at 7:40 am

    In new wordpress 3.0.1 if you want to change font size in tag cloud you need to manipulate “wp-includes/category-template.php”

    In line 562 just change the numbers for smallest and largest sizes.

    Hope it helps :)

  12. Blampy Blam on February 8, 2011 at 3:40 pm

    I, not long ago came throughout this site and also have enjoyed the content. I look forward to long term content and can definitely hyperlink to this and tell the folks I understand. Thank you.

  13. Trevor on February 25, 2011 at 4:18 pm

    I really hate going into those files but I guess if this is the only way to change the font size of the tags, I guess I will try it.

    I have been looking around for a while for this information and not really much out there. Thanks for the help.

  14. Timothy on May 13, 2011 at 7:51 pm

    Nice little wordpress hack – will definitely come in handy. I always used to be careful on which tag name I gave to certain posts lol.