WordPress Heat Map plugin

The WordPress Heat Map plugin provides you with three new template tags for displaying a heat map (aka weighted list) of your categories, tags and monthly archives. Activity in any given category, tag or month can be indicated by varying font sizes, color intensities or both. This plugin was largely inspired by Matt Kingston’s Weighted Categories plugin.

Heat map of monthly archives (with custom styling)

This plugin has only been tested with WordPress 2.6, however it will probably work with WordPress 2.3 or newer.

Download & Installation

  1. Download the WordPress Heat Map plugin: wp-heatmap_2_6.txt
  2. Rename it to “wp-heatmap.php”
  3. Upload the renamed file to your wordpress plugins directory
  4. Activate the plugin “WordPress Heat Map” in your plugins admin panel

Usage

This plugin provides three new template tags which are similar in use to the template tags provided by WordPress itself. The three new template tags are:

  • heatmap_categories(smallest, largest, ‘unit’, ‘cold’, ‘hot’, ‘before’, ‘after’, ‘exclude’, limit)
  • heatmap_tags(smallest, largest, ‘unit’, ‘cold’, ‘hot’, ‘before’, ‘after’, ‘exclude’, limit)
  • heatmap_archives(smallest, largest, ‘unit’, ‘cold’, ‘hot’, ‘before’, ‘after’)

The parameters for these template tags are the following:

  • smallest (integer): the smallest font size to use in the heat map, indicating the lowest activity. Defaults to 10.
  • largest (integer): the largest font size to use in the heat map, indicating the highest activity. Defaults to 36.
  • unit (string): the unit of the font sizes specified before, eg. ‘pt’, ‘px’, ‘em’, ‘%’, &c. Defaults to ‘pt’.
  • cold (string): the color to use in the heat map for indicating the lowest activity, without a leading ‘#’. Only three-digit color values are supported, eg. ’000′, ‘f00′, &c. Defaults to ’00f’ (blue).
  • hot (string): the color to use in the heat map for indicating the highest activity, without a leading ‘#’. Only three-digit color values are supported, eg. ‘fff’, ’00f’, &c. Defaults to ‘f00′ (red).
  • before (string): text to place before the link. Defaults to ”.
  • after (string): text to place after the link. Defaults to ‘ ’.
  • exclude (string): categories or tags to be excluded. Set this to ” if you don’t want to exclude any categories or tags. This must be in the form of an array, eg. ’1, 2, 3′. Defaults to ”. This parameter is only supported by heatmap_categories() and heatmap_tags().
  • limit (integer): the number of top categories or tags to be displayed. Set this to 0 if you want to display all categories or tags with no limit. Defaults to 0. This parameter is only supported by heatmap_categories() and heatmap_tags.

Example

Here’s an example of how to create a heat map of your top ten most active categories: The first two parameters define minimum and maximum font size, the third parameter defines the font size unit, the fourth parameter defines the color for least active entries to be black, the fifth parameter defines the color for most active entries to be a dark shade of red, the sixth parameter defines that there won’t be any text placed before each individual link, the seventh parameter defines that there are non-breaking spaces after each individual link. The eigth parameter is set to exclude no categories explicitly and the ninth parameter limits the number of displayed categories to the top ten most active categories.

     <?php heatmap_categories(12, 36, 'pt', '000', 'd01', '', '&nbsp;', '', 10); ?>

Here’s another example of how this plugin is used. The following code is placed in a template. The first two parameters define minimum and maximum font size, the third parameter defines the font size unit, the fourth parameter defines the color for least active entries to be black, the fifth parameter defines the color for most active entries to be a dark shade of red, the sixth and seventh parameters are opening and closing list-item tags which will be placed before and after each individual link. The template-tag is enclosed by unordered-list tags directly in the template html.

<ul class='heatmap'>
     <?php heatmap_archives(100, 150, '%', '000', 'd01', '<li>', '</li>'); ?>
</ul>

The following css can be used to style the heatmap and display list-items inline:

#content ul.heatmap {
	margin:0;
	padding:10px 0 30px 0;
}

#content ul.heatmap li {
	margin:0;
	padding:0;
	display:inline;
}

Note

If you want to only use varying font sizes in your heat map, simply set both the ‘cold’ parameter and the ‘hot’ parameter to the same arbitrary value. The color information will then be completely ignored and neither calculated nor included in the output.
If you want to only use varying color hues in your heat map, simply set both the ‘smallest’ parameter and the ‘largest’ parameter to the same arbitrary value. The font size information will then be completely ignored and neither calculated nor included in the output.

Would you like to comment?
Tell me what you think on Twitter: @chriwim.