Random Image Theme

Random Image is a theme for WordPress 1.5 or later, based on the default Kubrick theme, modified to display random header images. It also features a horizontal menu listing all available pages and supports Google AdSense. If you have an AdSense account, simply paste your AdSense account into adsense.php. The current version supports Sidebar Widgets.

You can download the Random Image theme here. Download the PhotoShop template for graphics here.

Modifying the theme

Here’s how it works if you’d like to modify the theme.
The random image is generated by this piece of PHP code in header.php:

function header_graphic() {
	echo "/images/";
	echo "kubrickheader".$num.".jpg";

The function ‘rand(0,10)’ will cause it to generate an image file name from ‘kubrickheader0.jpg’ through ‘kubrickheader10.jpg’. If you have a different number of images, change those numbers.

Make sure you place all of your image files in the /images/ subdirectory of the theme with the correct names. For best results, use the Photoshop template to create those images and insure they’re the proper size.

The image is actually displayed by several CSS entries and a DIV tag in header.php. This CSS entry picks the image to display and specifies it as the background image:

#header { background: url("<?php bloginfo('stylesheet_directory'); header_graphic(); ?>") no-repeat bottom center; }

The following CSS entries specify the size & position of the image:

#header 	{ margin: 0; padding: 1px; height: 198px; width: 758px; }
#headerimg 	{ margin: 7px 9px 0; height: 192px; width: 740px; }

Finally, the following bit of HTML displays the header graphic and adds the title:

<div id=header>
<a href="<?php echo get_settings('home'); ?>"><?php bloginfo('name'); ?></a>