The best way to create dynamic CSS for your WP theme
| January 24, 2011 | Posted by Ivan under WP For Developers |
When you design your own WordPress theme you probably use an option page with options that affect your theme appearance. If so, you need to create dynamic css for the theme and insert it into pages. There are several ways to do that but only one is the best. Firstly let’s enumerate them:
- Insert entire css into <style> tag using wp_head call
- Write dynamic CSS to a file, link to the file in the head.
- Using template_redirect hook to create CSS output based on a special GET variable.
- Style.php, which is linked to from the head, and outputs dynamic css.
They are listed in that order because they go from “best” to “worst”.
Some time ago I thought that the best way is the 3rd one but Otto (WordPress support forum moderator) has recently explained why is this order right. Read the explanation
Recent Comments