Tag cloud with rounded font sizes


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <ul>
  2. <?php
  3. $arr = wp_tag_cloud(array(
  4. 'smallest' => 8, // font size for the least used tag
  5. 'largest' => 40, // font size for the most used tag
  6. 'unit' => 'px', // font sizing choice (pt, em, px, etc)
  7. 'number' => 200, // maximum number of tags to show
  8. 'format' => 'array', // flat, list, or array. flat = spaces between; list = in li tags; array = does not echo results, returns array
  9. 'separator' => '', //
  10. 'orderby' => 'name', // name = alphabetical by name; count = by popularity
  11. 'order' => 'RAND', // starting from A, or starting from highest count
  12. 'exclude' => '', // ID's of tags to exclude, displays all except these
  13. 'include' => '', // ID's of tags to include, displays none except these
  14. 'link' => 'view', // view = links to tag view; edit = link to edit tag
  15. 'taxonomy' => 'post_tag', // post_tag, link_category, category - create tag clouds of any of these things
  16. 'echo' => true // set to false to return an array, not echo it
  17. ));
  18. foreach ($arr as $value) {
  19. $ptr1 = strpos($value,'font-size:');
  20. $ptr2 = strpos($value,'px');
  21. $px = round(substr($value,$ptr1+10,$ptr2-$ptr1-10));
  22. $value = substr($value, 0, $ptr1+10) . $px . substr($value, $ptr2);
  23. $ptr1 = strpos($value, "class=");
  24. $value = substr($value, 0, $ptr1+7) . 'color-' . $px . ' ' . substr($value, $ptr1+7);
  25. echo '<li>' . $value . '</li> ';
  26. }
  27. ?>
  28. </ul>

URL: http://digwp.com/2010/01/rounded-font-sizes-tag-clouds/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.