<body class=\"<?php $colors = array('253e76','340d0e','5d2901'); $bgColour = $colors[rand(0,count($colors)-1)]; echo 'bg-color-'.$bgColour.''; ?>\">
body { background: #f1eedd; color: #000; text-align: center; } .bg-color- { background: #f8dcef; background: #b2e5de; }
I'd like to try switching the background colour of my blog on each visit automatically, ala tweetCC.
I have the following script, placed it in the header.php of my WordPress theme folder but its not calling the colours.
<body class=\"<?php $colors = array('253e76','340d0e','5d2901'); $bgColour = $colors[rand(0,count($colors)-1)]; echo 'bg-color-'.$bgColour.''; ?>\">Any ideas? Thanks in advance.
For example <body class="bg-color-340d0e">. If you havent got that class in your css file nothing will happen ofcourse.
EDIT:
Not quite there, I can get the background switching two colours and default to white... This is my CSS:
body {
background: #f1eedd;
color: #000;
text-align: center;
}
.bg-color- {
background: #f8dcef;
background: #b2e5de;
}