Change the number of tags in the Tag Cloud Widget
Add this code to your child theme’s functions.php
file or via a plugin that allows custom functions to be added, such as the Code snippets plugin. Avoid adding custom code directly to your parent theme’s functions.php
file, as this will be wiped entirely when you update the theme.
add_filter( 'wp_generate_tag_cloud_data', 'tie_custom_code_tag_cloud_blocks' ); function tie_custom_code_tag_cloud_blocks( $tags_data ){ if( ! empty( $tags_data ) ){ array_splice( $tags_data, 15 ); } return $tags_data; }Old WordPress versions
/* * Change the number of tags in the Tag Cloud Widget */ add_filter( 'widget_tag_cloud_args', 'tie_custom_code_tag_cloud', 20 ); function tie_custom_code_tag_cloud( $args ){ if( isset($args['taxonomy']) && $args['taxonomy'] == 'post_tag' ){ $args['number'] = 15; } return $args; }