Adding taxonomy term to body_class on single.php
-
How can I add the name of the custom taxonomy term that a post belongs to on single.php into the body_class?
I’ve been able to add it when on taxonomy.php but when I click through from this page to a single post, the taxonomy term class disappears from the body tag.
I’ve checked that when on single.php the taxonomy term is recognised by adding this code in:
<?php if( false != get_the_term_list( $post->ID, 'bespoke_type' ) ) { echo 'The taxonomy is:' . get_the_term_list($post->ID,'bespoke_type', ' ', ' ', '' ); } ?>and this does indeed return the name of my taxonomy term (with a link to its taxonomy.php).
Any help would be marvelous.
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
The topic ‘Adding taxonomy term to body_class on single.php’ is closed to new replies.