
A poster recently asked, "How do I change the font size for the tag cloud widget? I can't find the CSS in my theme's style sheet."
The WordPress tag cloud plugin provides a visual representation of text data, used to depict post tags or categories on WordPress powered websites. This is an independent WordPress function. Themes designed for WordPress do not have CSS in their style sheets for formatting the WordPress tag cloud. The CSS for the tag cloud is built into the WordPress wp_tag_cloud() function, which is found in wp-includes/category-template.php. By design, the size of each tag is determined by how many times that particular tag has been assigned to posts. The font-size dimension is assigned to each tag at run time as inline CSS. There is no style sheet.
That being said, it is easy to change the sizes for tags using the widget_tag_cloud_args filter. There are two dimensions to change, smallest and largest. Add the following code to functions.php and set the size as you like it. The defaults are 8px for smallest and 22px for largest. In the example below, the smallest is set to 12px and the largest to 19px.
Parameters
Parameters that may be included in the above function are:
- smallest—The smallest tag (lowest count) is shown at size 8
- largest—The largest tag (highest count) is shown at size 22
- unit—Describes 'pt' (point) as the font-size unit for the smallest and largest values
- number—Displays at most 45 tags
- format—Displays the tags in flat (separated by whitespace) style
- separator—Displays whitespace between tags
- orderby—Order the tags by name
- order—Sort the tags in ASCENDING fashion
- exclude—Exclude no tags
- include—Include all tags
- topic_count_text_callback—Uses function default_topic_count_text (deprecated)
- link—view
- taxonomy—Use post tags for basis of cloud
- echo—echo the results
For further reerence, visit the wp_tag_cloud() page in the WordPress Codex: Here’s a link to the reference: http://codex.wordpress.org/Function_Reference/wp_tag_cloud
Hi, I read your post regarding how to control the size of the font inside the tag widget for WP tags, i hope you can help me in controling the size of the font in the Woocommerce Product Tag Widget.
None of my customers have ever asked for a change to the font size for Woocommerce Product Tag Widget. So I looked through the source code for the widget and it just calls the WordPress wp_tag_cloud() function. It passes the woocommerce_product_tag_cloud_widget_args filter to the WordPress function as a parameter. I have not tested this code, but the snippet below will get you pointed in the right direction:
add_filter( 'woocommerce_product_tag_cloud_widget_args', 'my_custom_product_tag_cloud_args');
function my_custom_product_tag_cloud_args( $args ) {
$args['smallest'] = 12; /* Set the smallest size to 12px */
$args['largest'] = 19; /* set the largest size to 19px */
return $args;
}