user1375823
user1375823

Reputation: 105

Wordpress styles from customiser into stylesheet

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

Upvotes: 0

Views: 55

Answers (1)

user2284357
user2284357

Reputation:

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.

Upvotes: 1

Related Questions