Support » Themes and Templates » Background for each page :-(

  • Resolved mzkorena



    I have followed every possible discussion on this topic and tried them all with no luck !!

    the code that I decided to stick to until it works (sticking to it cause people said it does work) is in my child theme’s page.php :

    [CSS moderated as per the Forum Rules. Please just post a link to your site.]

    could anyone point out what Im doing wrong here ? … my mind is not really coding-friendly, so please bare with me 🙂
    Thanks in advance, oh and my parent theme is twenty eleven 1.3

Viewing 9 replies - 1 through 9 (of 9 total)
  • Moderator Kathryn


    Each page already comes with a unique body class. All you need to do is then reference that class in your CSS to apply the desired styles.

    For example… look in the generated source code in a web browser on a given page. You may see something like this:

    <body class="page page-id-27 page-template-default single-author singular two-column left-sidebar highlander-enabled highlander-light">

    page-id-27 is the unique class for that page. I can now reference it in my CSS like this and give it a purple background:

    .page-id-27 {
       background-color: #b0b;

    And so on, for each page and post.

    Does that make sense?

    Moderator Kathryn


    p.s. if you look in your generated code and don’t see a unique body class, your theme may be missing the function which adds that feature. Look in header.php and add it if it’s not already there:

    <body <?php body_class(); ?>>

    Moderator Kathryn


    Thank you very much for your reply,

    your explanation makes perfect sense. I did inspect my website, and did find the returned &class :
    <body class=”page page-id-22 page-template page-template-showcase-php logged-in admin-bar custom-background single-author one-column content”>

    and tried the bit of code you provided … with no luck :-(, I suspect its the “custom background” section of the class, I understand that it shouldnt be there unless Im using a custom setting for my background, how do I prevent it from being used ?, could it be that I am overriding my

    .page-id-22 {
       background-color: #b0b;

    code ?

    Moderator Kathryn


    Could you provide a link to your site so I can take a peek?

    You can also try:

    .page-id-22 {
       background-color: #b0b !important;

    The !important declaration should in theory override any other setting, but CSS inheritance rules can sometimes be finicky.

    Moderator Kathryn


    Can you also try going into the background area of your theme settings in the admin area and remove any background colour you may have set there?

    Thank you very much for your help, I have managed to remove the custom-background by adding an action with “remove-custom-background” to my child’s function.php, now the code you provided works 🙂 …
    body class for each page tip was the key to finding out whats wrong with my code, so thank you very much for that !
    my website is on a localhost, not yet available on web, so I cant link to it …
    honestly, I find web programming rather complicated ! Even though I do embedded systems programming as a job 🙁

    Thanks again, your tips were more than helpful 🙂

    Moderator Kathryn


    My pleasure.

    Peace All,

    I am so confused. So i am trying to add a separate background for each page. I am using the autofocus theme. I have a static page as my home page (i also cant figure out why my menu has a double link for home and welcome when they are the same page?)I created my backgrounds using inkscape as png files and uploaded them to my media files. I have tried about 4 different ways to do this but every time I do I either get a different error message saying that I put the code in the wrong place either in my header.php or my page.php anything i add to the stylesheet just doesnt show up. i tried adding the body class statement with page id underneath my my body class line but it just turned the background white.

    <body class=”<?php sandbox_body_class() ?>”>
    <body class=”home page page-id-1 page-template page-template-pagehome-php logged-in”>

    i feel like im staring at some foreign object and the spark just has not caught on yet.

    also here are some other ways that people have posted to change backgrounds

    I downloaded a few different background plugins with no success, some i just dont understand how to use and others when i try to use them, i get the same background image showing for all the pages,

    i need like html/css/wordpress for dummies type of help here. this is my first time working with any of this.

    here is a link to the site

    ive arranged the dimensions of the background image to workwith the media already loaded onto the page, so it looks like the page flows naturally.

    PLEASE help

    any and all help s greatly appreciated.

    thanx much

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Background for each page :-(’ is closed to new replies.