• Resolved stephanie_2

    (@stephanie_2)


    hi,
    how can i change my background by page id ?

    i tried this:

    body {
    
            background-color: #000;
            background-image: url("back2.jpg");
            background-attachment: fixed;
    
    	color: #999999;
    
    }
    
    body.page-id-2 {
    background: #000;
            background-image: url("back1.jpg");
    }
    
    body.page-id-6 {
    background: #000;
            background-image: url("back.jpg");
    }
    body.page-id-8 {
    background: #000;
            background-image: url("back3.jpg");
    }

    doesn’t work:(
    thanks
    s.

Viewing 8 replies - 1 through 8 (of 8 total)
  • did you try to refresh the browser cache by reloading the page, or by pressing ‘ctrl f5’ ?

    does you theme actually use body_class(); ?

    maybe try to use background-color: #000;

    still, theoretically, is should work.

    is your code in style.css?

    where are the images located?

    do you have a link where this problem can be seen?

    Thread Starter stephanie_2

    (@stephanie_2)

    thank you alchymyth! …shure make alway refresh and empty cache.
    i also changed it to background-color:
    doesn’t work
    what is a body_class();???
    where and how do i have to have it?
    thank you!!!
    s.

    Thread Starter stephanie_2

    (@stephanie_2)

    ok, i put this: <body class=”page-id-<?php the_ID(); ?>”>
    in my header.php before the header close container…
    have no idea how and why it should function or not…

    Moderator keesiemeijer

    (@keesiemeijer)

    body_class()
    try this:

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

    Thread Starter stephanie_2

    (@stephanie_2)

    oh keesiemeijer! IT WORXXXX! thank you so much!!!!:)

    Stephanie: NO! that line must be after the </head> tag since the “<body>” is where the page beings.

    You should try this:

    <head ... >
    ... the head content (descriptions, title, meta, css, js, etc) ...
    </head>
    
    <body <?php body_class(); ?> >
    ... the site html/css/php/etc content ..
    </body>

    The body_class() is a WordPress function that automatically adds the right classes to the body tag of your theme.

    Let me know if this help you to solve your issue.

    Regards.

    Oh.. glad to read that!

    Thread Starter stephanie_2

    (@stephanie_2)

    thanks davoscript! …sorry i mean head container

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘change background by page id’ is closed to new replies.