Posted By

ariunbolor on 04/26/11


Tagged

css php wordpress


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

hkamci


WordPress Random Background


 / Published in: PHP
 

Do not forget to name images you want to use for background like 1.jpg, 2.jpg, 3.jpg etc.

  1. html,
  2. body { height: 100%; }
  3.  
  4. img#bg {
  5. position:fixed;
  6. top:0;
  7. left:0;
  8. width:100%;
  9. height:100%;
  10. }
  11.  
  12. <body>
  13.  
  14.  
  15. <?php $random_image = rand(1, 5); /*let's choose random image...*/ ?>
  16. <img id="bg" alt="" src="<?php bloginfo('stylesheet_directory');?>/images/<?php echo $random_image; ?>.jpg" />

Report this snippet  

You need to login to post a comment.