Limit number of tags in WordPress tag cloud widget

 In Widgets

If your WordPress website has a lot of tags (and growing), you may probably struggle with bad looking messy list inside the WordPress tag cloud widget. But you would rather show descent number of tags instead of removing the widget, right?

This simple snippet will do a trick:


//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;
Recommended Posts

Start typing and press Enter to search