Limiting the number of tags in a tag cloud

By August 28, 2014 Software, Technical

Just a very quick post as I was looking at how to do this and tried a few methods that didn’t work first.

Firstly, the code.

add_filter('widget_tag_cloud_args','set_number_tags');
function set_number_tags($args) {
$args = array('number' => 20);
return $args;
}

This needs to go in the functions.php file OF YOUR THEME. Don’t put it in the wp-includes/functions.php file as you may find your site falling flat on its backside.

In my case, I put this straight after the opening php tag and it works fine.

Leave a Reply