Home › Forums › Add-ons › Options Page › Help with get_field values on Options Page › Reply To: Help with get_field values on Options Page
How do you include your styles in the page? it doesn’t work in the style.css but you can implement custom styles by using a styles.php like this:
function my_dymanic_styles(){
$about_color = get_field('about_color', 'options');
$custom_css = "
a{ color:{$about_color};}
";
return my_css_strip_whitespace($custom_css);
}
Put this in your functions.php
function my_css_strip_whitespace($css){
$replace = array(
"#/\*.*?\*/#s" => "", // Strip C style comments.
"#\s\s+#" => " ", // Strip excess whitespace.
);
$search = array_keys($replace);
$css = preg_replace($search, $replace, $css);
$replace = array(
": " => ":",
"; " => ";",
" {" => "{",
" }" => "}",
", " => ",",
"{ " => "{",
";}" => "}", // Strip optional semicolons.
",\n" => ",", // Don't wrap multiple selectors.
"\n}" => "}", // Don't wrap closing braces.
"} " => "}\n", // Put each rule on it's own line.
);
$search = array_keys($replace);
$css = str_replace($search, $replace, $css);
return trim($css);
}
/**
* Dynamic Styles additions.
*/
require get_template_directory() . '/inc/style.php'; //make sure you correct the directory and file path you use
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.