Different backgroundcolors for different pages
-
I read the topic “[resolved] Different background color on each page”.
It says:By “page,” I assume you are using that in the WP-Admin sense of the word. In that case, go into the template’s page.php (if there is one). If you see a <body> tag near the top, that’s our destination. Depending on the theme author, <body> might actually be in header.php
Then replace the body tag with something like this:
<?php if (is_page()){ ?> <body class="page-<?php the_ID(); ?>"> <?php }else{ <body> <?php } ?>
That’s for if the body tag was in header.php. If it’s in page.php, you wouldn’t need all the conditions.
Then, just go into your style sheet and add a single line for each page, like this:
body.page-1{background:#fff;} body.page-2{background:#f00;}
etc. You’ll find the page ID’s on the “Manage Posts” screen.
(You might actually need to write something like “body.page-1 container{}” if that’s how your CSS is set up.)
Now what I have in header.php is
<body id='top' <?php body_class($k_body_class);?> >
How do I combine this body-tag with the suggested change?Anyone have a solution?
Thanks in advance!!
- The topic ‘Different backgroundcolors for different pages’ is closed to new replies.