Support » Fixing WordPress » wp_tag_cloud: Tag counts Not respecting size limits

  • The following code:

    <?php wp_tag_cloud(‘smallest=10&largest=10&number=10&format=list&orderby=count&order=DESC’); ?>

    Generates a cloud in list format, but the font sizes still vary, even though I’ve specified the same size for smallest and largest. Is there any way around this bug?

    Also, I don’t see anything on the codex page for the function about how to display the number of finds for each tag listed (e.g. “geek (23)” ). But when I view source, the found counts are present in the title attribute of the href for each tag. Is there any way to surface this information?


Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi shacker,

    I’ve run into the same two problems.
    The first one (font sizes still vary) is solved through editing the largest only by a marginal higher number than the smallest value.

    Example with em instead of px:
    <?php wp_tag_cloud('format=list&smallest=1&largest=1.01&unit=em'); ?>

    As you can see I changed the value for the largest by only 0.01 em which equals 1%. You can barely recognize the difference.

    A solution for the second problem (display number of post associated with each tag) is highly appreciated.


    Found a fix for the second problem as well by editing a core file : 0
    – so this is not an elegant solution.

    Edit /wp-includes/category-template.php at line 381 (WP v.2.3.1) so it contains the variabel $count.

    For example:
    . "$unit;'>$tag</a> ($count)";
    . "$unit;'>$tag ($count)</a>";

    I noticed the same thing with the Tag Cloud — if I specified the same size for my minimum and maximum it ignored it and still generated different sized tags, albeit with slight differences.

    What I discovered through experimentation is that I needed to include &unit=px at some point in the argument string for wp_tag_cloud. Why that should make a difference I don’t know.



    I can’t seem to get WP to acknowledge the wp_tag_cloud arguments either. Nothing seems to take. Anyone have any other suggestions?

    Just wanted to say thanks to mikimiklos – I used both your solutions and it worked extremely well! So nice when a change actually works and takes less than 2 minutes! 🙂

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘wp_tag_cloud: Tag counts Not respecting size limits’ is closed to new replies.