WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] change background by page id (9 posts)

  1. stephanie_2
    Member
    Posted 4 years ago #

    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.

  2. alchymyth
    Forum Moderator
    Posted 4 years ago #

    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?

  3. stephanie_2
    Member
    Posted 4 years ago #

    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.

  4. stephanie_2
    Member
    Posted 4 years ago #

    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...

  5. keesiemeijer
    moderator
    Posted 4 years ago #

    body_class()
    try this:

    <body <?php body_class(); ?>>
  6. stephanie_2
    Member
    Posted 4 years ago #

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

  7. davoscript
    Member
    Posted 4 years ago #

    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.

  8. davoscript
    Member
    Posted 4 years ago #

    Oh.. glad to read that!

  9. stephanie_2
    Member
    Posted 4 years ago #

    thanks davoscript! ...sorry i mean head container

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.