Adjust WordPress Tag CLoud Font Size image

WordPress Tag Cloud Font Size

Adjust WordPress Tag CLoud Font Size image

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.

https://gist.github.com/vfontjr/e75fb543c0b426a89c73bfeebf6e0a4c#file-set_tag_cloud_font_size-php

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