I am currently displaying posts from a CPT. Each has a taxonomy term from a parent. I would like to create a function that would color the background of a div of particular parent terms.
Here is my set up:
Lets call this Cars:
Domestic
--Dodge --Ford --ChryslerImport
--Honda --Toyota --KiaEuropean
--BMW --Benz
The parent is Domestic, Import, European.
My posts displays as follows:
Ford
Post Title
Post ContentToyota
Post Title
Post Content
Etc.
My goal is to color the DIV that the child term is held in. For example:
<div class="car_type">Ford</div> (background green)
Post Title<br>
Post Content<br>
<div class="car_type">Toyota</div> (background red)
Post Title<br>
Post Content<br>
I am trying to construct the following:
if (parent_term == 'domestic'){
.car_type{
background-color:green;
}
}
if (parent_term == 'import'){
.car_type{
background-color: red;
}
}
So far I have checked out get_terms. Any help pointing me in the right direction would be amazing.
Thank you, I hope this makes sense.