Support

Account

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