0

So I'm creating a WP theme and I have started building customisation for it, currently I have the styles go to the header and they are inline. Is there any way I can put them into a stylesheet after the options(get theme mod) have retrieved the information? Hope that makes sense. Or is it okay to have all the styles being inline in the header? It just seems really messy...

Thank you

user1375823
  • 95
  • 1
  • 12
  • 1
    Are the options universal, like a dark and a light theme, or do you give them options to change fonts, and colors per their choosing? – Ryan B Nov 25 '13 at 20:14
  • It's the options to change colours etc. Is that okay? – user1375823 Nov 25 '13 at 20:29
  • 1
    That's fine, just a little more work on your end. Check out: http://stackoverflow.com/questions/566203/changing-css-values-with-javascript for starters. – Ryan B Nov 25 '13 at 20:36

1 Answers1

1

Basic answer is : No, can not.

Because, the stylesheet is a css file, your get_theme_mod() or get_option() functions are wp core functions working in php script. Data is fetched through those functions and printed in header through wp_head(), the whole process is on the php files only.

So, no wp core function can print it inside stylesheet.

Also, I have never seen any theme or plugin doing so. But if you are very interested a custom built function can be written using 3 php functions: fopen() fwrite() fclose()

That function will write desired string inside the stylesheet, but have to be parsed in functions.php or atleast before <head></head>

I think it is an fairly unique idea (some do this in custom template editors), subjected to views of other people.