You’ll have to adjust the markup to suit your specific needs, but the easiest solution would use a post_class
filter on the post_class()
template tag, to output appropriate classes.
For example, in your template, you need to call post_class()
, such as:
<div <?php post_class(); ?>>
<div class="car_type">Ford</div> (background green)
Post Title<br>
Post Content<br>
</div>
Then, filter post_class
, using your term:
function wpse123081_add_post_classes( $classes, $class, $postid ) {
// Custom Tax
if ( 'carsCPT' == get_post_type( $postid ) ) {
foreach ( (array) get_the_terms( $postid, 'carsTax' ) as $term ) {
if ( empty( $term->slug ) )
continue;
$classes[] = 'term-' . sanitize_html_class( $term->slug, $term->term_id );
}
}
}
add_filter( 'post_class', 'wpse123081_add_post_classes', 10, 3 );
This will turn this:
<div <?php post_class(); ?>>
…into this:
<div class="term-carTaxTerm">
(along with other classes, of course)
And you can target your CSS accordingly.