Title: Random header images
Last modified: August 21, 2016

---

# Random header images

 *  Resolved [Dmitri51](https://wordpress.org/support/users/dmitri51/)
 * (@dmitri51)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/random-header-images-1/)
 * First of all what a brilliant theme. Thanks!
 * Now the question ….
 * I’d like to have random header images, instead of 1 static header image.
 * In [this post](http://wordpress.org/support/topic/different-header-images-for-different-pages-1?replies=4)
   you say
 * ‘Hopefully I’ll get time to build in the standard header image functionality 
   in the not too distant future, so that plugins like the one above can be used.’
 * Did you already have the time to build this? If not, are you still planning to
   do so (I hope so!)
 * Thanx in advance.

Viewing 7 replies - 1 through 7 (of 7 total)

 *  Thread Starter [Dmitri51](https://wordpress.org/support/users/dmitri51/)
 * (@dmitri51)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/random-header-images-1/#post-5013057)
 * Any news on this?
 *  [bdbrown](https://wordpress.org/support/users/bdbrown/)
 * (@bdbrown)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/random-header-images-1/#post-5013058)
 * Hi Dmitri51. It doesn’t appear that the theme header image functionality has 
   changed. However, I ran across this [Random Header Images](http://wpmu.tripawds.com/2011/01/18/an-overview-of-the-new-tripawds/)
   post. Gave it a try by taking the site-title, site-description and site-image
   code out of header.php and dropping in the code from that post. Worked without
   any problems.
 *  [rjcowan](https://wordpress.org/support/users/rjcowan/)
 * (@rjcowan)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/random-header-images-1/#post-5013059)
 * bdbrown – do you have a copy of the code you dropped into the header.php?
 *  [bdbrown](https://wordpress.org/support/users/bdbrown/)
 * (@bdbrown)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/random-header-images-1/#post-5013060)
 * There are several ways to do this; here’s one way:
    1. Create your header images;
   they should all be the same size and file type (jpg or png or whatever). 2. Place
   them all in the same folder; something like /wp-content/uploads/header_images/.
   3. Give the image files all the same base name which includes an incremental 
   number; like “header_img1.jpg”, “header_img2.jpg”, etc. 4. Copy header.php from
   the parent theme to your child theme. 5. In header.php either comment out or 
   remove this block of code which normally displays the site title and description,
   or the theme header image:
 *     ```
       <?php if ( ot_get_option('header-image') == '' ): ?>
       <div class="group pad">
       	<?php echo alx_site_title(); ?>
       	<?php if ( ot_get_option('site-description') != 'off' ): ?><p class="site-description"><?php bloginfo( 'description' ); ?></p><?php endif; ?>
       	<?php if ( ot_get_option('header-ads') == 'on' ): ?>
       	<div id="header-ads">
       		<?php dynamic_sidebar( 'header-ads' ); ?>
       	</div><!--/#header-ads-->
       	<?php endif; ?>
       </div>
       <?php endif; ?>
       <?php if ( ot_get_option('header-image') ): ?>
       	<a href="<?php echo home_url('/'); ?>" rel="home">
       		<img class="site-image" src="<?php echo ot_get_option('header-image'); ?>" alt="<?php get_bloginfo('name'); ?>">
       	</a>
       <?php endif; ?>
       ```
   
 * 6. Then add this block of code and:
    (1) change the path to the location of your
   header images (2) change the “rand” upper number to the highest number of your
   image file names (see #3 above) (3) change the file name suffix to “jpg” or “
   png” or whatever you used (4) change the width and height to whatever you used
   when creating the images (5) change the “alt” text to suit your needs
 *     ```
       <!-- Random Headers -->
       <a href="<?php echo home_url('/'); ?>" rel="home">
         <img  class="site-image" src="http://yoursite.com/wp-content/uploads/header_images/header_img<?php echo(rand(1,9)); ?>.png" width="1350" height="400" alt="My Header Image">
       </a>
       <!-- Random Headers -->
       ```
   
 *  [rjcowan](https://wordpress.org/support/users/rjcowan/)
 * (@rjcowan)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/random-header-images-1/#post-5013061)
 * bdbrown,
 * Wasnt sure what code to remove so thanks for the heads up. Worked a treat.
 *  Thread Starter [Dmitri51](https://wordpress.org/support/users/dmitri51/)
 * (@dmitri51)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/random-header-images-1/#post-5013062)
 * Hi bdbrown,
 * Thanks for sharing. I’ll try your solution!
 *  Thread Starter [Dmitri51](https://wordpress.org/support/users/dmitri51/)
 * (@dmitri51)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/random-header-images-1/#post-5013063)
 * BDBrown,
 * Just tried it and it works like a charm!
 * Thanx

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Random header images’ is closed to new replies.

 * ![](https://i0.wp.com/themes.svn.wordpress.org/hueman/3.7.27/screenshot.png)
 * Hueman
 * [Support Threads](https://wordpress.org/support/theme/hueman/)
 * [Active Topics](https://wordpress.org/support/theme/hueman/active/)
 * [Unresolved Topics](https://wordpress.org/support/theme/hueman/unresolved/)
 * [Reviews](https://wordpress.org/support/theme/hueman/reviews/)

 * 7 replies
 * 3 participants
 * Last reply from: [Dmitri51](https://wordpress.org/support/users/dmitri51/)
 * Last activity: [11 years, 3 months ago](https://wordpress.org/support/topic/random-header-images-1/#post-5013063)
 * Status: resolved