With custom post type, i need to use category slug for my class (css).
<?php
global $post;
$terms = wp_get_post_terms($post->ID, 'typeresources');
if ($terms) {
$output = array();
foreach ($terms as $term) {
if ($term->term_id != 14)
{
$output[] = '<div >' .$term->name .'</div>';
}
}
echo join( ' ', $output );
};
?>
Would like to add at my "cat-resources class" the categroy slug
How can i do that ?
CodePudding user response:
There you go.
global $post;
$terms = wp_get_post_terms($post->ID, 'typeresources');
if ($terms) {
$output = array();
foreach ($terms as $term) {
if ($term->term_id != 14) {
$output[] = '<div hljs-variable">$term->slug.'">' .$term->name .'</div>';
}
}
echo join( ' ', $output );
};