Random background image php
-
Hello, I am using WP 3.5.1, twenty twelve child theme and PHP 5.2 on my server.
I am trying to use a php script(that works on my other websites) in order to get random background-image but it’s not working:CSS:
body { background: url(<?php echo $selectedBg; ?>) no-repeat fixed; }
PHP:
<?php $bg = array('1.jpg','2.jpg','3.jpg','4.jpg','5.jpg'); $i = rand(0, count($bg)-1); $selectedBg = "$bg[$i]"; ?>
my php file is in the same folder as the jpg’s.
Any ideas?
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Random background image php’ is closed to new replies.