Support » Fixing WordPress » Random background image

  • Resolved oval

    (@oval)


    Hi guys, I would like to place a random background image function on my main wordpress page so that each time the user visits the blog or refreshes the page, a random background image appears on the entire page.

    I had acquired a javascript for the random bg image and tried to implement it in the header.php but I had no luck. Is there any other way I can do this? Any advice or info is appreciated.

    Best,
    Oval

Viewing 9 replies - 1 through 9 (of 9 total)
  • Ya I use one on my blog, not using javascript but a php script called rotate.php

    simple HTML, but adjust to what you need inside your header.php file

    <background=”rotate.php”>

    Matt of wordpress fame! has an example here:
    http://photomatt.net/scripts/randomimage/

    peace

    Dear Iscifi,

    Thank you so much for the tip! Works like a charm.

    Oval

    I will use it too 😉

    This is great code. Simple & elegant.

    I do have one question on implementation.

    I am rotating the background image for the pages.

    However, I want to use a different random background image on the index.php and single.php templates. I am using the same code to get the image in each file

    <style type="text/css">body {
    	background-image: url(../../../images/backgrounds/rotate.php);
    }

    However, when I go from page to page my FireFox cache is loading the same background image instead of getting a new one (Internet Explorer 7 seems to load it new each time). If I <shift>+”Refresh” I get a different background each time but unless I do the force refresh each page loads with the cached background.

    Is there a good way to work around this?

    I assume I can use a different “random image” directory for each template and since I would call the random image from a different place there would not be the same one in the cache, but that seems very clunky.

    Any ideas?

    I have noticed this too. Solution?

    how could i do a rotating image in the header? same code?

    That’s what I’m using it for…

    Hi guys,

    It has been a few weeks. Does anyone have a clue on the different background on each page?

    If you insert the style tag `<style type=”text/css”>body {
    background-image: url(../../../images/backgrounds/rotate.php);
    }` into a text widget at the bottom of your sidebar it should reload with every page load.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Random background image’ is closed to new replies.