wp_tag_cloud: Tag counts + Not respecting size limits (6 posts)

  1. shacker
    Posted 8 years ago #

    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?


  2. mikimiklos
    Posted 8 years ago #

    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.


  3. mikimiklos
    Posted 8 years ago #

    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>";

  4. allyngibson
    Posted 8 years ago #

    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.

  5. Linh
    Posted 8 years ago #

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

  6. swekarl
    Posted 7 years ago #

    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! :)

Topic Closed

This topic has been closed to new replies.

About this Topic