CSS styles depending on column entries?

There is a custom record type, and depending on the chosen heading you select a background color for the record. How to do it humanly?
For example, choose a category No. 1 for one record - the background was red, choose a category # 2 for another record - the background was blue, etc.
June 10th 19 at 15:04
2 answers
June 10th 19 at 15:06
Option light
body_class zhezh

Option does not light
term meta in the term of custom taxonomy to it cling to ColorPicker, in record get the value of this field
I will approach the first option. And tell me, please, I correctly realized that I need a loop to walk through body_class, adding slugs of each taxonomy heading? That is, each category in WP to cling to their styles? - tillman18 commented on June 10th 19 at 15:09
no, body class and so automatically delave - Earlene_Stehr34 commented on June 10th 19 at 15:12
Simply it does not add the classes that I need, am I doing something wrong? Here's what he added: class="page-template page-template-education-page-template-education-php page page-id-27 logged-in admin-bar no-customize-support tax _masterslider _msp_version_3.2.0". - tillman18 commented on June 10th 19 at 15:15
And Yes, a little protupil. The classes that I showed, they term not single.
Yes, it is necessary to add a filter class in a single term, something like this
add_filter( 'body_class', 'wpp_my_tax_slug_class' );

wpp_my_tax_slug_class function( $classes ) {
 global $post;

 $terms = get_the_terms( $post->ID, 'my_tax' );
 if ( !empty($terms) ) {
 foreach ($terms as $term) {
 $classes[] = 'my_tax-' . $term->slug;

 return $classes;
- Earlene_Stehr34 commented on June 10th 19 at 15:18
in, thought so, thank you, I'll try) I Have a little question for you: the standard taxonomy in the record column, it is a separate taxonomy for the standard "Entry" or it is like a template taxonomy. Just when I create a custom record type in the plugin CPT UI and choose Category (WP Core), this custom type in the columns of I are given headings, in the type "Record", and I would like to in new type of those headings was not. As it should be? For custom record type you need to create a custom taxnomy headings? - tillman18 commented on June 10th 19 at 15:21
June 10th 19 at 15:08
As an option in database in table "categories" you will have a field color which you pass to the front which is the thing draws. In the admin area or wherever you are creating the site, there do some colorpicker with the choice of colours for headings.

Find more questions by tags WordPress