I am trying to figure out how to add my custom taxonomy for tags to the post class css when I already have added the custom taxonomy for categories. The code Im currently using to add the category taxonomy is –
<?php $terms = get_the_terms( $post->ID, 'videoscategory' ); ?>
<div class="box<?php foreach( $terms as $term ) echo ' ' . $term->slug; ?>">
This works fine but I also need to add a class for tags I’ve created with a custom taxonomy. I came across this code that will add the regular tags, but I need to use my custom tags.
<?php $tags = get_the_tags();
if( $tags ) : ?>
<?php foreach( $tags as $tag ) { ?>
<span class="<?php echo $tag->slug; ?>"><a href="<?php echo get_tag_link($tag->term_id); ?>"><?php echo $tag->name; ?></a></span>
<?php } ?>
<?php endif; ?>
Thanks.
Ok I figured out how to add the terms to div’s class –
In the code I have first the category, then the post type, then a custom taxonomy tag term assigned to it –