full size background jQuery with different background per page
  • laurelaure March 2011

    Hello
    I try to have a different background per page. I try to do so with custom field and put on my index.php this code

    <style type=“text/css”>
    container{
    background-image: url(‘<?php echo get_post_meta($post->ID, ‘background-image‘, true); ?>
    }
    </style>
    then add a background-image custom field with the absolute adress... but does'not work.
    I try with the php
    <?php if(is_page('1') ):
    $bgimg="image1";
    elseif(is_page('2') ):
    $bgimg="image3";
    else :
    $bgimg="image2";
    endif; ?>
     
    <body id="<?php echo $bg;?>">
    <div id="container">
    <img src="http://www.monsite/site/wp-content/themes/graphene/images/'<?=$bg?>.jpg" alt="" />


    between head and/head and add the image in the css like this
    image1{background:url(mon_url_monimage.jpg}
    image1{background:url(mon_url_monimage.jpg}


    but I don't know how to link up with your jquery plugin.
    Can you help me , have you an idea ? Thank you

  • cbavotacbavota March 2011

    You can't use a background image so there is no need for any CSS. All you need to do is change the actual image tag on each page:

    <?php
    if(is_page(1)) {
    $imgsrc = 'http://yoursite.com/image/image1.jpg';
    } elseif(is_page(2)) {
    $imgsrc = 'http://yoursite.com/image/image2.jpg';
    }
    ?>


    Then you image tag should look like this:
    <img src="<?php echo $imgsrc; ?>" alt="" />

  • laurelaure March 2011

    Thank you very much it works fine.

This discussion has been closed.
← All Discussions

Hey there!

Take a look around, and if you would like to add a comment or start a discussion, register by clicking on the button below.

Register

Categories

In this Discussion

Tagged