Support » Fixing WordPress » How to add post_tags to body_class()

Viewing 1 replies (of 1 total)
  • Went back to a function i tried a night before when i think i was a bit tired and i must have slipped an error.
    here it is:

    // add tags in body
        function tags_id_class($classes) {
              global $post;
              $tag_names = wp_get_post_tags ($post->ID, array('fields' => 'names' ) );
              foreach ($tag_names as $tag)
                 $classes[] = $tag;
              return $classes;
        }
        add_filter('body_class', 'tags_id_class');

    Now when calling <body <php? body_class(); ?>> it is outputting the tag name as well.
    Hope it helps someone else.

Viewing 1 replies (of 1 total)
  • The topic ‘How to add post_tags to body_class()’ is closed to new replies.