Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: Different Backgrounds


chrishajer
Participant

@chrishajer

It can be done with PHP.

I’ve never done the random thing, but the Cutline theme for WordPress offers this functionality. You can read about it here:

http://cutline.tubetorial.com/totally-random-header-images-for-cutline/

I think you could adapt that for your uses.

In WordPress, for a specific background tied to a specific page, I just do something like this in header.php:

<div id="container" style="background: #fff url('<?php bloginfo('template_directory'); ?>/images/<?php echo $post->ID; ?>.jpg') left top no-repeat;">

That gives the container div the background image of the post ID.jpg, so if you were viewing post 52, you would have a background image of 52.jpg. You could easily adapt this to bbPress calls by using the forum number and $forum_id, whichever div you want a background for (#wrapper or #main?) and then the proper location of your images (whether they are stored in your template folder or your forum root or something.) It fails OK too since there is a color code for the background and that is used if the image cannot be found (I think that’s what happens anyway.)

Let me know if that makes sense. This is how I’ve done it in WordPress, but the same approach will work for bbPress I think.

Skip to toolbar