How to limit number of tags cloud widget in WordPress


by 0


By default tag cloud widget of WordPress will display all your tags, it make your wiget too long. So in this tutorial, i will show you how to limit number of tags cloud widget in WordPress. Follow step by step to make your look website clean.


This simple snippet to help you litmit number tags cloud in WordPress without install new plugin.

1. Open your function.php in your current theme and paste this code to end of this file

//Register tag cloud filter callback
add_filter('widget_tag_cloud_args', 'tag_widget_limit');

//Limit number of tags inside widget
function tag_widget_limit($args){

 //Check if taxonomy option inside widget is set to tags
 if(isset($args['taxonomy']) && $args['taxonomy'] == 'post_tag'){
  $args['number'] = 10; //Limit number of tags

 return $args;

2. Save and upload it to your hosting. F5 and see the result !

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>