• Every other page is fine but when you go to a post’s page the background.
    jholway.com is the site.

    Here is a blog post (with no background)

    I am using a bit of PHP that has the background images change when you refresh the page but I can’t understand why it works everywhere but there.

    Here’s the php:
    <?php
    $bg = array(‘bg-01.jpg’, ‘bg-02.jpg’, ‘bg-03.jpg’, ‘bg-04.jpg’, ‘bg-05.jpg’ ); // array of filenames

    $i = rand(0, count($bg)-1); // generate random number size of the array
    $selectedBg = “$bg[$i]”; // set variable equal to which random filename was chosen
    ?>

Viewing 5 replies - 1 through 5 (of 5 total)
  • Can you pastebin.com the whole code that deals with changing the background image? From looking at your source code it looks like you might just have the image URL misconfigured.

    Also I noticed on the post page that global.css cannot be found.

    Thread Starter atotalpirate

    (@atotalpirate)

    Here’s i picked up the background changing code also the global stylesheet is only needed for the js slider on the frontpage.

    And the code you have in your header.php is the exact piece of code listed on that tutorial in the second piece of code?

    Thread Starter atotalpirate

    (@atotalpirate)

    Yes except the paths to the images are correct. The images work fine and the php seems to work fine on every page but a specific posts page.

    Where do you have the images stored for the backgrounds? What is the directory structure?

    If you go into your source code for a blog post using Chrome Developer Tools, you’ll see the following listed in the <head> section

    html{
    	background: url(../../../../images/bg-02.jpg) no-repeat center center fixed;
    	etc etc
    }

    If you add an additional ../ to the above URL structure the background image displays. So its just a matter of determining where the images are being stored and then echoing out the php to look in that location whether you’re on the home page or a post page.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Page Background won't display in Posts page only’ is closed to new replies.