Some people are never satisfied. They liked the Super Simple Random Header Image but they wanted more . They wanted the header images to change every 10-15 seconds without having to refresh the page. So after a little head scratching and searching I’ve found the solution.
This tutorial will be aimed at Artisteer generated themes, but it will work for virtually any WordPress theme. This will also only work with Artisteer themes with square header images. Rounded headers have two images, a .png that provides the round corners and a .jpg that is positioned on top.
The first thing you need to do is create your new header images. They need to be the exact same size as your original image. You can make as many as you want. Create a new folder called ‘headers’ in the images folder of your theme. You need to name the header images as follows:
Now open your header.php file in your favorite text editor and find the following code…
<?php wp_head(); ?>
Then insert this code directly above it…
Next change the body tag to look like this…
This bit of code will enable the rotation script but not until after the page loads.
The next thing that we need to do is pre-load our header images so that there is no delay in displaying our headers. The easiest way to do this is in an invisible DIV. We will tell the browser to load the images and then we will style the DIV to display:none.
Add the following code right after the < body > tag…
<div style="width:1px; height:1px; display:none;"> <img src="<?php bloginfo('template_url'); ?>/images/headers/header_1.jpg" /> <img src="<?php bloginfo('template_url'); ?>/images/headers/header_2.jpg" /> <img src="<?php bloginfo('template_url'); ?>/images/headers/header_3.jpg" /> <img src="<?php bloginfo('template_url'); ?>/images/headers/header_4.jpg" /> <img src="<?php bloginfo('template_url'); ?>/images/headers/header_5.jpg" /> </div>
In this example we’re rotating 5 different images. If you want more or less you just have to make sure and adjust the code accordingly.
That’s about it. Remember if you have any questions just drop me a line.