chrishau Posted March 26, 2009 Share Posted March 26, 2009 Hi! I have a problem with creating a random header rotator for my website. In my CSS the header is referred to by this code: #header h1 a {display:block;background:url(images/banner1.jpg) no-repeat left;height:180px;} I wrote this to put in my header.php (Im using wordpress) right over the <?php wp_head(); ?> so that it would overwrite what the css says. Code follows: <style type="text/css"> #header h1 a {display:block;background:url(<?php $stylesarray = array("banner1","banner2","banner3"); $random = $stylesarray[rand(0,count($stylesarray)-1)]; echo "url(images/".$random.".jpg);" ?>) no-repeat left;height:180px;} </style> I have created banner1.jpg to banner3.jpg but I still just get the banner1.jpg that is written in the css file. Any tips on how to solve this? Thanks in advance! My website is btw www.175days.no Link to comment https://forums.phpfreaks.com/topic/151248-php-within-css/ Share on other sites More sharing options...
monkeytooth Posted March 26, 2009 Share Posted March 26, 2009 It wont work, WP is calling its CSS files after your PHP based style addin. Meaning being called afterword its over riding your input as it is using the same names/id's only way to do what you want it to alter WP all together in the head and how it handles the CSS files. so it will work with what you want to do mind you that has its kick backs to as when you log in and set a theme it will still do random unless set up properly. Its going to take more then a "quick hack" to do it but it is possible I assume. Link to comment https://forums.phpfreaks.com/topic/151248-php-within-css/#findComment-794585 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.