Use wp_register_style
and wp_enqueue_style
to add the stylesheet. DO NOT simply add a stylesheet link to wp_head
. Queuing styles allows other plugins or themes to modify the stylesheet if necessary.
Your stylesheet can be a .php
file:
1 2 | wp_register_style('myStyleSheet', 'my-stylesheet.php'); wp_enqueue_style( 'myStyleSheet'); |
my-stylesheet.php would look like this:
1 2 3 4 5 6 7 8 9 10 11 | <?php // We'll be outputting CSS header('Content-type: text/css'); include('my-plugin-data.php'); ?> body { background: <?php echo $my_background_variable; ?>; font-size: <?php echo $my_font_size; ?>; } |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.