Title: BugiuAlex's Replies | WordPress.org

---

# BugiuAlex

  [  ](https://wordpress.org/support/users/bugiualex/)

 *   [Profile](https://wordpress.org/support/users/bugiualex/)
 *   [Topics Started](https://wordpress.org/support/users/bugiualex/topics/)
 *   [Replies Created](https://wordpress.org/support/users/bugiualex/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/bugiualex/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/bugiualex/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/bugiualex/engagements/)
 *   [Favorites](https://wordpress.org/support/users/bugiualex/favorites/)

 Search replies:

## Forum Replies Created

Viewing 1 replies (of 1 total)

 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [How to add post_tags to body_class()](https://wordpress.org/support/topic/how-to-add-post_tags-to-body_class/)
 *  Thread Starter [BugiuAlex](https://wordpress.org/support/users/bugiualex/)
 * (@bugiualex)
 * [14 years, 7 months ago](https://wordpress.org/support/topic/how-to-add-post_tags-to-body_class/#post-2314360)
 * 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)