Modify the WordPress Tag Cloud Widget Easily


There are numerous ways of how to modify the WordPress tag cloud widget, but there’s an easy way to modify it. I searched about how to modify such, and landed on different blogs sharing different methods to modify the widget. I also landed on this page which tells everyone to modify the WordPress core. But I don’t think it’s the best solution to customize your WordPress Tag cloud.

In the same blog post I linked above, one guy also shared his trick in modifying the WordPress tag cloud. He said that modifying the functions.php is the best way. You never need to hack the WordPress core, and it’s a NO NO to modify core files, because when you update your WordPress blog, your modifications will be overwritten. If you’ve read the comment that I linked, you’ll noticed that there are so many unnecessary lines of code in his “trick” to modify WP’s tag cloud widget.

If you don’t want to edit WP core files and you don’t want to copy and paste unnecessary lines of code, then use my method. Just copy paste the code below and paste in your functions.php.

add_filter('widget_tag_cloud_args', my_tag_cloud_args );
function my_tag_cloud_args($in){
return 'smallest=10&largest=20&number=100&orderby=name&unit=px';
}

Just modify the small integer, largest integer and number of tags to suit your needs. You can also modify the order of your tags if you want it to be by name or by count. The unit can be pt, px, em, or %.

You can also check the WordPress Codex function reference for wp_tag_cloud to know more parameters in the wp_tag_cloud function.

That’s all for today! Thank you for reading!

UPDATE: If you want a Better Tag Cloud, check this out! It’s literally a BETTER tag cloud! Hat tip to Maria for sharing this awesome plugin!


Comments

6 responses to “Modify the WordPress Tag Cloud Widget Easily”

  1. Thanks for the link love!

    Unfortunately, the post you linked to is VERY old. I’ve since switched to a plugin that offers far more flexibility: Better Tag Cloud. You can find it at http://www.nkuttler.de/wordpress/nktagcloud/

    1. Bryan Veloso Avatar
      Bryan Veloso

      Hi Maria,

      You’re very much welcome! Wow! Thanks for sharing the Better Tag Cloud! I will include it in this post so that others who are looking for it can easily find it! 🙂

  2. Just what I needed. Thanks for sharing bryan!

  3. Kristóf Avatar
    Kristóf

    Hi Bryan,

    I tried this method, and work fine with my tag cloud, but it change my category cloud too to tag cloud. Do you know any solution for this problem?

    Thanks for the info!

    1. Bryan Veloso Avatar
      Bryan Veloso

      Yes, it will modify the category cloud as well. The only workaround I can think of right now is disable the widget and manually display the category cloud in your sidebar or wherever you want:

      http://codex.wordpress.org/Function_Reference/wp_tag_cloud#Display_a_Category_Cloud

    2. Kristóf Avatar
      Kristóf

      Don’t you know any way to filter only selected args or filter everything except the taxonomy?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.