Monday, April 26, 2021

WP - Display all tags in a tag cloud

You may have lot of tags but in your WordPress not all tags are displayed in the tag cloud. To display all or more tags there is simple solution.

Go to Appearance->Theme Editor

Then in Theme Files select functions.php.

Add the following at the end:

//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'] = 500; //Limit number of tags
 }
 
 return $args;
}

Save the file.

If you want to display even more tags or less tags then change the number of tags to value which suites you.

If you want this behavior for WP categories then instead of 'post_tag' use 'category'.