9. Display a Random Header Image on Your WordPress Blog The problem. This is not really a problem, but many WordPress users would love to be able to display a random header image to their readers. The solution. 1. Once you have selected some images to be your header images, name them 1.jpg, 2.jpg, 3.jpg and so on. You can use as many images as you want. 2. Upload the images to your wp-content/themes/yourtheme/images directory. 3. Open header.php and paste the following code in it: view plaincopy to clipboardprint? 1. $num = rand(1,10); //Get a random number between 1 and 10, assuming 10 is the total number of header images you have 2. <div id=”header” style=”background:transparent url(images/.jpg) no-repeat top left;”> $num = rand(1,10); //Get a random number between 1 and 10, assuming 10 is the total number of header images you have <div id=”header” style=”background:transparent url(images/.jpg) no-repeat top left;”> 4. You’re done! Each page or post of your blog will now display a random header image. Code explanation. Nothing hard here. We simply initialized a $num variable using the PHP rand() function to get a random number between 1 and 10. Then, we concatenate the result of the $num variable to the path of the theme we are using. Source: