How to Limit Tags in Tag Cloud Widget in WordPress

Have you ever tried to use the Tag Cloud widget in your WordPress but it appeared way too messy to use? Here at Top Five Advisor, we have over 100 tags that we have setup and we’re just getting started. Unfortunately, the default display of the tag cloud widget is to show all of your tags and increase in size depending on the tag use on your content.

WordPress Tag Cloud WidgetYou may notice that we have the following screenshot on the left displaying on the bottom of our website and you may be wondering how we did it.

Thankfully, all you need to do is make a quick edit in your functions.php file and you’ll be able to customize how many tags will appear in your widget area.

Simply change the number 5 on the “$args[‘number’] = 5;” line and the number you set will be the total tags allowed to be shown in that widget area, whether it is in your sidebar or footer areas.

Here’s the code snippet that you need to add to your functions.php:

// Limit Tags in Tag Cloud Widget
add_filter('widget_tag_cloud_args', 'tag_widget_limit');
function tag_widget_limit($args){
 if(isset($args['taxonomy']) && $args['taxonomy'] == 'post_tag'){
  $args['number'] = 5; // <-- Tags Limit

 return $args;

What this will do is show your most popular tags in the tag cloud depending on the number you set. In our case, the screenshot in this post represents the 5 most popular tags as of the time of this posting.

About Scott Buehler

Scott is the owner and founder of Top Five Advisor. He specializes in business to business products and services. He offers digital marketing services to any local business that wants to drive traffic and customers from the Internet including search, pay per click and social media marketing. This page is maintained by Scott Buehler.

Click Here to Leave a Comment Below 0 comments