I have this situation where I need to filter specific post type posts by its taxonomies (there 3 different ones) and since I am using Isotope, I need them in my class element. I already made it work with one and I believe I took the 'long' road. I dont really work that much with php, this is what I could get from codex...
1) I get custom post type entries 2) inside
$terms = get_the_terms( $post->ID, 'resource_roles' );
if ( $terms && ! is_wp_error( $terms ) ) :
$links = array();
foreach ( $terms as $term ) {
$links[] = $term->name;
}
$tax_links = join( " ", str_replace(' ', '-', $links));
$tax = strtolower($tax_links);
else :
$tax = '';
endif;
echo '<div class="color-shape resource-block ' . $tax . '">';
echo '<h1>' . the_title() . '</h1>';
echo '</div>';
As seen in the code, now it ads 'resource_roles' taxonomy elements, now I need to add 'resource_media' and 'resource_theme'. :/ I believe there is shorter way, community, can you help me make this code neat and short?