Support » Fixing WordPress » Help in creating different background images for static pages?

  • I am trying to create a different header image for certain (not all) static pages on my site, Penelope Room.

    As in, when viewing Scott’s Room, Scott would like to use the image cudgel.jpg instead of the usual morning.jpg as a header image.

    I’m using the theme: Greenbay V2 by DL2 Media and in it the header seems to be what you see above the header image. And what I’m calling the header image is called the background image in the stylesheet:
    border-top:1px solid #A19585;

    border-bottom:1px solid #A19585;
    color: #A19585;
    width: 100%;
    margin-top: 10px;
    height: 150px;
    background-image:url(‘morning.jpg’); background-repeat:repeat-x

    The theme does not use page.php but it does have a header.php. Although in the header.php, there is code for the section above the image and this for the image:

    <div id=”topheader” style=”width: 750px; height: 66px”>
    <?php bloginfo(‘name’); ?>
    <div style=”float: right; padding-right: 5px;”><?php bloginfo(‘description’); ?>
    <div id=”header” onclick=”location.href=’’;” style=”cursor: pointer;”></div>

    I’ve gone through what seems like a hundred ways to have different headers for specific pages, but those aren’t working for me (although, I’m more than ready to assume it’s a user problem).

    Any suggestions? Is there more information I can give? I’m hoping for the least messy way possible, but I’m up for trying anything. Thank you!

Viewing 7 replies - 1 through 7 (of 7 total)
  • SugaredHarpy


    Is there any help for this? Thanks.



    It’s not very easy…
    You either have to use a lot of conditionals in your header.php file and/or use Page templates that call different header files.
    Plus, you’ll have to alter the stylesheet, too, maybe have separate stylesheets.
    Not having any Page template it makes it even more complicated.



    Ah, I was worried about that. Thank you.



    I have a way to do it but I’m having a problem as well. It basically involves naming the image after the page, like page_image.jpg:

    <img src=”<?php the_title(); ?>_image.jpg” />

    It works, BUT not if your page has multiple words in the title. I am combing the docs for how to replace the_title() with something that would reference the Post Slug rather than the full page title but I can’t find anything. Help!



    It was an issue with Permalinks. OP: I don’t know if my metod would help you or not but it’s allowing me to have a different image in the same place on each page.

    EDIT: Never mind, still not working.



    It helps to know another way to play with it, but sadly, I can’t get that to work either. Good luck and let me know how it goes.

    Hi there,

    I had a similar problem about changing different elements through CSS on a page by page base. The solution might help you too.

    in header.php


    <body id="<?php if (have_posts()) : while (have_posts()) : the_post(); echo 'page-'; the_id(); endwhile; endif; ?>">

    Lets say the ID for your “Home” page is “2”. If you want to create a different background for header section in “Home” page

    add to your CSS document
    #page-2 #header {background-image:url('cudgel.jpg')}

    You can do this to any page as long as you know their ID’s.

    There is also an alternative, if you don’t like to deal with ID’s (like me) 🙂


    <body id="<?php if (have_posts()) : while (have_posts()) : the_post(); print_slug(); endwhile; endif; ?>">

    Add this function to classes.php

    function print_slug() {
    	$my_post_id = get_post(get_the_id());
    	$slug = $my_post_id->post_name;
    	echo $slug;

    lastly change your CSS

    e.g. for “Home” page
    #home #header {background-image:url('cudgel.jpg')}

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Help in creating different background images for static pages?’ is closed to new replies.