Hi Dmitri51. It doesn’t appear that the theme header image functionality has changed. However, I ran across this Random Header Images 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.
bdbrown – do you have a copy of the code you dropped into the header.php?
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 -->
bdbrown,
Wasnt sure what code to remove so thanks for the heads up. Worked a treat.
Hi bdbrown,
Thanks for sharing. I’ll try your solution!
BDBrown,
Just tried it and it works like a charm!
Thanx