Dejo Dekic
Dejo Dekic

Reputation: 2126

Why is my CSS/PHP stylesheet not applied to my site?

I am using following (simplified) code for my PHP stylesheet

<?php header("Content-type: text/css; charset: UTF-8"); ?>      
/* Our dynamic styles go here */
/* We will check BOTH sidebars are there so we can adjust width of our content */
<?php if ( is_active_sidebar('secondary') && is_active_sidebar('main') ) {

 ?>

 #blogs{
 float: right;
 width: 530px;
 }

<?php } ?>

Now when I view source of my webpage I am getting this (exactly as should be):

<link rel="stylesheet" type="text/css" media="all" href="http://www.mypage.com/wordpressdevelopment/wp-content/themes/Endless_Theme/functions/dynamic_css.php">

So when I click my link above (Endless_Theme/functions/dynamic_css.php)
I am getting this output (so now I know that my PHP/CSS script is working) :

/* Our dynamic styles go here */
/* We will check BOTH sidebars are there so we can adjust width of our content */
   #blogs{
   float: right;
   width: 530px;
   }

But the problem is that my CSS/PHP is not being applied to my webpage!
Can someone tell me please what I am doing wrong here?

You can see my PAGE HERE

It should display one sidebar on right side and another on left side but it is not working (but strange thing is that same code IS WORKING on my LOCALL machine).

Upvotes: 0

Views: 1776

Answers (2)

Orangepill
Orangepill

Reputation: 24645

Browsers heavily cache css files.

Either send an expires header in the css or cache bust the css include... basically change the url every time it is requested so the browser will see it as a new asset.

<link rel="stylesheet" type="text/css" media="all" href="http://www.mypage.com/wordpressdevelopment/wp-content/themes/Endless_Theme/functions/dynamic_css.php?cb=<?= time(); ?>">

Upvotes: 0

johnkavanagh
johnkavanagh

Reputation: 4674

Your file isn't valid CSS. Try cutting out the commented chunks of PHP - I suspect you'll find it works then!

Upvotes: 3

Related Questions