最新的 WordPress 版本
代码: 全选
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;
}
代码: 全选
/*
* 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;
}