Skip to main content

Limit Tags Cloud in Wordpress

in order to limit the wordpress tags cloud you can use these two ways , you can choose whatever you want

open your functions.php file in your theme and add this code

 

Method 1

function custom_tag_cloud_widget() {
    $args = array(
        'smallest' => 8,
        'largest' => 22,
        'unit' => 'pt',
        'number' => 15,
        'format' => 'flat',
        'separator' => "\n",
        'orderby' => 'name',
        'order' => 'ASC',
        'exclude' => '',
        'include' => '',
        'link' => 'view',
        'taxonomy' => 'post_tag',
        'post_type' => '',
        'echo' => true
    );
    return $args;
}
add_filter( 'widget_tag_cloud_args', 'custom_tag_cloud_widget' );

Method 2

 

function prefix_widget_tag_cloud_args( $args ) {
    $args['number'] = 5;
    return $args;
}
add_filter( 'widget_tag_cloud_args',    'prefix_widget_tag_cloud_args',      10, 1 );