How to Limit number of tags in cloud widget for WordPress

Posted by
December 24, 2018

If your website has a lot of tags, and these tags are looking messy list inside the widget. So Instead of showing all tags, you can show a decent number of tags.

Here is the simple snippet will do a trick. Add this code to your theme functions.php file


//Show only 20 of tags inside widget
function blog_7v_tag_widget_limit($args) {
    //Check if taxonomy option inside widget is set to tags
    if (isset($args['taxonomy']) & $args['taxonomy'] == 'post_tag') {
        $args['number'] = 20;
    return $args;

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


read more