Sunday 6 October 2013

Display Random Header Images in WordPress

Display Random Header Images in WordPress


randomheaderimages


Most blog designs get boring if they have a huge header picture and it is static. This is when this tutorial comes in to make your header images dynamic because it rotates on each visit. You can select as many images as you want to rotate randomly. It brings life to a blog.


First you need to name your images in this format:



  • headerimage_1.gif

  • headerimage_2.gif

  • headerimage_3.gif


You must separate the name with an underscore. You can change the headerimage text to himage or anything you like.


Once you have done that paste the following code in your header.php where you would like the images to be displayed or in any other file.


<img src="http://path_to_images/headerimage_<?php echo(rand(1,3)); ?>.gif"
width="image_width" height="image_height" alt="image_alt_text" />

Make sure that you change the number 3 if you decide to do more than 3 images. This code is not exclusive for WordPress,

it will work with any php based platform.



Display Random Header Images in WordPress

No comments:

Post a Comment