Community Forums › Forums › Archived Forums › Design Tips and Tricks › How To Rotate Header Image In Minimum Theme?
- This topic has 15 replies, 3 voices, and was last updated 11 years, 9 months ago by Kevin Muldoon.
-
AuthorPosts
-
November 21, 2012 at 11:08 pm #1249Kevin MuldoonMember
This is a query regarding the minimum theme. I'd like to rotate the header image using a number of different images.
I've removed the is_home if statement from the header image function (in functions.php) so that the header image displays on the whole site.
/** Add the featured image section */
add_action( 'genesis_after_header', 'minimum_featured_image' );
function minimum_featured_image() {echo '<div id="featured-image"><img src="'. get_stylesheet_directory_uri() . '/images/sample.jpg" /></div>';
}Does anyone have the code which would enable me to rotate 3 or 4 different images. I'd rather do something simple using the function rather than using a plugin.
thanks,
Kevin
Kevin Muldoon – Blogger & WordPress Fanatic.
November 24, 2012 at 11:37 am #1489Kevin MuldoonMemberNovember 25, 2012 at 11:18 am #1571Doak HeggenessMemberYour title confuses me. I think you want to have several images rotate in lieu of the single image on the 'front page' per the demo? This image is not in the header. If so you can...
1) Hardcode 'Flexslider' in a new page...front-page.php if using static pages settings. However I think you would prefer the following....
2) Create a widget area using the 'genesis_after_header' hook and insert a slider...ie 'Genesis Responsive Slider' or the 'Soliloquy Slider'. See Minimum functions.php for examples in adding and registering a widget.
I hope this helps!
Doak Heggeness, WordPress Development | Website
November 25, 2012 at 11:49 am #1576Kevin MuldoonMemberHi Doak,
Thanks for replying. It's not a slider I was looking for. If you look at the code above in the functions.php file, I only need to randomate the images that are displayed.
I managed to get it working by changing:
echo ‘<div id=”featured-image”><img src=”‘. get_stylesheet_directory_uri() . ‘/images/sample.jpg” />
to
$images[] = 'http://www.sitecom/wp-content/themes/minimum/images/header-images/image1.jpg';
$images[] = 'http://www.site.com/wp-content/themes/minimum/images/header-images/image2.jpg';
$images[] = 'http://www.site.com/wp-content/themes/minimum/images/header-images/image3.jpg';
$images[] = 'http://www.site.com/wp-content/themes/minimum/images/header-images/image4.jpg';
echo '<div id="featured-image"><img src="'.$images[rand(0,count($images)-1)].'" /></div>';
Kevin Muldoon – Blogger & WordPress Fanatic.
November 25, 2012 at 12:06 pm #1579MarcParticipantIf you would consider having a different random image every time the home page is loaded, rather than timed rotating/sliding/fading images, you can easily integrate and use Matt Mullenweg's random image script here - http://ma.tt/scripts/randomimage/ . I have used it a couple of times with Minimum 2.0 and it works fine.
I like the random option it because it does not slow the page down any from how it is "out-of-the-box" yet offers a different image each time the page is visited.
November 25, 2012 at 12:10 pm #1580Kevin MuldoonMemberHi Marc,
That was actually the first script I tried as I used it in the past. For some reason, I couldn't get it to work. Not sure what I done wrong.
Kevin
Kevin Muldoon – Blogger & WordPress Fanatic.
November 25, 2012 at 12:16 pm #1583MarcParticipantKevin, seems like I "stepped" on your reply above. Either method will get you there. I like Matt's because I don't have to worry about any image names or conventions, just ftp them (whatever they are named) into the dedicated folder.
November 25, 2012 at 12:19 pm #1584Kevin MuldoonMemberI may try the script again if you have got it working. When I tried it last time it gave me a fatal error. I assumed it was because the script was so old and a new version of PHP clashes with it.
Kevin Muldoon – Blogger & WordPress Fanatic.
November 25, 2012 at 12:22 pm #1585MarcParticipantCongrats on your success. I am glad there are alternatives, if I need. Thank you!
Script conflicts arise. I have Matt's script running on this site -
And on my local server with another site and RC3.5 + Minimum 2.0
But you can never tell ....
November 25, 2012 at 12:30 pm #1586MarcParticipantFWIW, Below is the modified function code related to Matt's script from the site linked above. (Note: Matt's script name is changed) -
/** Add the featured image section */
add_action( 'genesis_after_header', 'minimum_featured_image' );
function minimum_featured_image() {
if ( is_home() ) {
echo '<div id="featured-image"><img src="'. get_stylesheet_directory_uri() . '/images/header-images/minimum-header-rotate.php" alt="College Station and Bryan TX event and wedding photography" title="College Station and Bryan TX event and wedding photography" /></div>';
}
/** elseif ( is_singular( array( 'post', 'page' ) ) && has_post_thumbnail() ){
echo '<div id="featured-image">';
echo get_the_post_thumbnail($thumbnail->ID, 'header');
echo '</div>';
} */
}
November 25, 2012 at 12:33 pm #1588Kevin MuldoonMemberThanks Marc. Really appreciate that. Just to check, are you using the rotate script found on this page (from 2003).
Kevin Muldoon – Blogger & WordPress Fanatic.
November 25, 2012 at 1:05 pm #1592MarcParticipantYes, exactly. The only deviation is to name the script "minimum-header-rotate.php"
November 25, 2012 at 1:39 pm #1600Kevin MuldoonMemberNovember 25, 2012 at 2:16 pm #1608MarcParticipantKevin, Email me at [email protected] and I will provide you site login credentials to the photographer's site if you want to explore differences as to why it is working there and not on yours.
November 25, 2012 at 3:34 pm #1626Kevin MuldoonMemberNovember 25, 2012 at 5:34 pm #1641Kevin MuldoonMemberThanks for your help Marc. The file you sent me worked. I must have copied the wrong code somewhere.
Feel free to close the thread now:)
Kevin Muldoon – Blogger & WordPress Fanatic.
-
AuthorPosts
- The topic ‘How To Rotate Header Image In Minimum Theme?’ is closed to new replies.