Wordpress tag list with CSS classes


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



Copy this code and paste it in your HTML
  1. <ul id="tag_grid">
  2. <?php
  3. $tags = get_tags(array('orderby' => 'count', 'order' => 'DESC', 'number' => 25));
  4.  
  5. foreach ($tags as $tag) {
  6. if ($tag->count < 5) {
  7. echo('<li class="tagclass1">');
  8. } else if ($tag->count < 15) {
  9. echo('<li class="tagclass2">');
  10. } else if ($tag->count < 25) {
  11. echo('<li class="tagclass3">');
  12. } else {
  13. echo('<li class="tagclass4">');
  14. }
  15.  
  16. echo('<a href="' . get_tag_link($tag->term_id) . '" rel="tag">' . $tag->name . "</a></li>\n");
  17. }
  18. ?>
  19. </ul>

URL: http://www.positivespaceblog.com/archives/how-to-create-a-tag-grid-and-evolve-past-the-cloud/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.