Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 25th, 2012  |  syntax: None  |  size: 0.42 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Wordpress - Add tags as classes? (post_class)
  2. function tag_to_class($classes) {
  3.         global $post;
  4.         foreach((get_the_tags($post->ID)) as $tag)
  5.             $tags[] = $tag->name;
  6.             return $tags;
  7.     }
  8.     add_filter('post_class', 'tag_to_class');
  9.     add_filter('body_class', 'tag_to_class');
  10.        
  11. <div class="<?php the_tags("", " ", "");?>">
  12.        
  13. <div class="<?php post_class(the_tags("", " ", "")); ?>">