When working with the WordPress Theme Customizer, one of the things you may find yourself doing is writing out inline styles into one of the templates for your theme. Most likely, this will happen within the context of your
There is somewhat of a solution to this, though.
Whenever I’ m working with the Theme Customizer, I make sure to do several things:
In addition to those two files, I also maintain a template part (or partial, as some refer to it), that I normally call
customizer.php. The file may look something like this:
As you can tell from the code, the file is responsible for checking the values of the theme modifications via the WordPress API and then updating them accordingly via inline styles.
Though we can’t write this out directly into a separate CSS file (which would be ideal), we can write it out into a separate file that helps with maintainability throughout the course of a theme’s lifetime. Then, once it’s defined, you can easily include it in the
header template with the following line (just after the
It’s simple, sure, but things like this can go along way into making it much easier to keep your code logically separated into cohesive components that can be easily developed and maintained over time.