• Hello!

    Is there a css / php code that makes possible showing a background image on the main page of my blog and another different background on single pages?

    I’ve heard it’s possible and it’s not difficult.

Viewing 1 replies (of 1 total)
  • Something like:

    <?php if( is_home() || is_front_page() ) $backround_image = 'image1.jpg';
    else $backround_image = 'image2.jpg';
    $bg = get_bloginfo('template_directory'); ?>
    ?>
    <style type = "text/css">
    body{background-image:url(<?php echo get_bloginfo('stylesheet_directory') .' /images/' . $backround_image;?>}
    </style>

    in the <head></head> section of your theme’s header.php template file should work. It assumes that the two images will be present in your theme’s images folder.

Viewing 1 replies (of 1 total)
  • The topic ‘Different codes for main page and single posts’ is closed to new replies.