Different content background image for each Page
-
This is an attempt to place a simple tested solution to using different content background images on each individual WordPress Page.
To give credit where it is due, I borrowed code from this thread HERE, did a couple of minor tweaks, tested it and can say it works perfectly to accomplish this one task.
First I created 4 different background images and 3 different test pages. The 4th image is used as a default content background for any pages I did not define in my stylesheet.
In the page.php file replace:
<div id="content">
With:
<?php $class = ''; if (is_page('test')) { $class = 'test'; } elseif (is_page('test2')) { $class = 'test2'; } elseif (is_page('test3')) { $class = 'test3'; } ?> <div id="content"<?php if($class) echo ' class=' . $class . ''; ?>>
In your stylesheet file find your content style block and replace with as follows (changing dimensions etc. to suit your theme):
#content { background:url(images/bg-default.jpg) ; width: 960px; min-height: 340px; background-repeat: no-repeat; background-position: right bottom; overflow: hidden; } #content.test { background: url(images/bg-test.jpg); } #content.test2 { background: url(images/bg-test2.jpg); } #content.test3 { background: url(images/bg-test3.jpg); }
Note that It is not necessary to repeat the entire CSS block for each page.
- The topic ‘Different content background image for each Page’ is closed to new replies.