Instead of directly printing the CSS in the header (which is not the best practice) you can add your CSS via wp_add_inline_csswp_add_inline_style
. Hook into the wp_enqueue_scripts
and add your CSS after your theme's stylesheet.
So, this is how your code is gonna look like:
add_action('wp_enqueue_scripts', 'theme_dynamic_css');
function theme_dynamic_css(){
global $my_theme_options;
if (isset($my_theme_options['custom-css'])) {
$custom_css .= $my_theme_options['custom-css']."\r\n";
}
wp_add_inline_csswp_add_inline_style('style', $custom_css);
}
You should use this after you already enqueued your theme's main stylesheet, by using:
wp_enqueue_style( 'style', get_stylesheet_uri());
Also pay attention to the ID that you've chosen for your stylesheet.