html - How do I get my PHP variable to echo inside my CSS stylesheet? -


ok, i'm building wordpress theme allow client assign colour each category. proving quite difficult when comes making stylesheet read code.

i'm using code

.thumbnail-section {     width: 100%;     height: 450px;     overflow: hidden;     background: <?php echo $category_color; ?> ; } 

but reason php isn't being noticed.

i've placed following code @ top of stylesheet , changed .css extension .php

<?php header("content-type: text/css; charset: utf-8"); ?> 

edit: sorry, forgot mention. variable being defined category. here's code:

<?php             $category = get_the_category();             $the_category_id = $category[0]->cat_id;              if(function_exists('rl_color')){                 $rl_category_color = rl_color($the_category_id);             }         ?> 

multiple ways

one set .htaccess:

addtype application/x-httpd-php .css 

and echo data in .css file.


Comments