How to add post_tags to body_class()
-
Hello and thx for taking the time to look over this.
I am trying to add a body class for a single post. The body class i want it to be the post tag(s).
I tried using the function for category, but it didn’t work. Here is the code:
// add category nicenames in body and post class function category_id_class($classes) { global $post; foreach((get_the_tags($post->ID)) as $tag) $classes[] = $tag->name; return $classes; } add_filter('post_class', 'category_id_class'); add_filter('body_class', 'category_id_class');
Been at it for a few good hours, didn’t find anything specific on google. And i am not very good with php.
Thank you in advance
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘How to add post_tags to body_class()’ is closed to new replies.