Basically I’ve applied this way to show certain colors on pages like search.php or a list on home.
What it does is it reads a variable that gets a field from WP, if that field is equal to a certain number then it adds a class name which in CSS has a color
Now the field on a single page is there, though whenever I add the ‘if system’ that I applied on the other pages it doesn’t add the class in the body on header.php. Now this works correctly on other pages(Not globally but individually) but not here for some reason.
On the header.php:
<?php
//Body class
if($mem_id == 1) { $class="color1"; }
if($mem_id == 2) { $class="color2"; }
if($mem_id == 3) { $class="color3"; }
if($mem_id == 4) { $class="color4"; }
if($mem_id == 5) { $class="color5"; }
if($mem_id == 6) { $class="color6"; }
if($mem_id == 7) { $class="color7"; }
if($mem_id == 8) { $class="color8"; }
if($mem_id == 9) { $class="color9"; }
?>
<body <?php body_class($class); ?>>
In other pages:
$mem_id = get_field('memtype_id');