How to limit the number of tags in WordPress tag cloud widget?

By default, WordPress tag cloud widget display the complete list of tags you are using on your blog. But if you have lot of tags, it look like a complete mess. Also, there is no option on dashboard to limit the number of tags in your default tag cloud widget. But you can easily do this by using following code.

To Limit the number of tags in your tag cloud widget paste the following code in your functions.php file.

//limit number of tags cloud widget
add_filter('widget_tag_cloud_args', 'limit_tag_in_tag_cloud_widget');
function limit_tag_in_tag_cloud_widget($args){
	if(isset($args['taxonomy']) && $args['taxonomy'] == 'post_tag'){
		$args['number'] = 10; //Limit number of tags
	return $args;



  1. Thank you, this is exactly what I needed. Can’t understand why this is not an option in the WordPress tag cloud setup by default.


Leave a Comment.