Support Forum
Hello,
I made some custom fields with color pickers to change the custom type post colors only on some pages.
The issue is that if I keep the custom field empty, overwite my CSS body variables, how can I avoid that?
I want to change color only when I have actually selected the color for each page.
Hese is a code i used in the wp_head:
'<div>
<style type="text/css">
.single {
--theme-color: <?php
$theme_color = rwmb_meta('theme_color_fdl', ['storage_type' => 'custom_table', 'table' => 'wp_mb_free_downloads_fields']);
echo $theme_color;
?>;
;
--meta-scrolled-color: <?php
$theme_color = rwmb_meta('theme_color_fdl', ['storage_type' => 'custom_table', 'table' => 'wp_mb_free_downloads_fields']);
echo $theme_color;
?>;
;
--shadow-theme-color: <?php
$theme_shadow_color = rwmb_meta('theme_shadow_color_fdl', ['storage_type' => 'custom_table', 'table' => 'wp_mb_free_downloads_fields']);
echo $theme_shadow_color;
?>;
;
--color1: <?php
$color_1 = rwmb_meta('color_1_fdl', ['storage_type' => 'custom_table', 'table' => 'wp_mb_free_downloads_fields']);
echo $color_1;
?>;
;
--color2: <?php
$color_2 = rwmb_meta('color_2_fdl', ['storage_type' => 'custom_table', 'table' => 'wp_mb_free_downloads_fields']);
echo $color_2;
?>;
;
--color3: <?php
$color_3 = rwmb_meta('color_3_fdl', ['storage_type' => 'custom_table', 'table' => 'wp_mb_free_downloads_fields']);
echo $color_3;
?>;
;
}
</style>
</div>'
This is the issue I'm facing:
I kept the field emplty:
https://drive.google.com/file/d/1-dBfV0SYjDWfwjKqJtCYXDloVDlXIiur/view?usp=sharing
They overwrite my css variables:
https://drive.google.com/file/d/1uKrRcrdvIQahnd7S7b8kqHkkK7BEu6CY/view?usp=sharing
https://drive.google.com/file/d/14FrCrgFo09CP7ttu6UeXkq_ABqhHUczM/view?usp=sharing
Is there a way to avoid it? I don't want to select colors for every page but only for a few of them.
Thanks