WP Twenty Eleven – Header Image Only On Home Page

Goal: Display header image only on Home page (WP Twenty Eleven) and no header images on any other pages/posts

Details: Rotating images in header on Home page, via WP Rotator plugin

Solution: Use Conditional Tags in header.php:

File: header.php (Copy & paste header.php from Twenty Eleven parent folder to Twenty Eleven Child folder)

Replace (lines 78-97):

				// Check to see if the header image has been removed
				$header_image = get_header_image();
				if ( ! empty( $header_image ) ) :
			<a href="<?php echo esc_url( home_url( '/' ) ); ?>">
					// The header image
					// Check if this is a post or page, if it has a thumbnail, and if it's a big one
					if ( is_singular() &&
							has_post_thumbnail( $post->ID ) &&
							( /* $src, $width, $height */ $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), array( HEADER_IMAGE_WIDTH, HEADER_IMAGE_WIDTH ) ) ) &&
							$image[1] >= HEADER_IMAGE_WIDTH ) :
						// Houston, we have a new header image!
						echo get_the_post_thumbnail( $post->ID, 'post-thumbnail' );
					else : ?>
					<img src="<?php header_image(); ?>" width="<?php echo HEADER_IMAGE_WIDTH; ?>" height="<?php echo HEADER_IMAGE_HEIGHT; ?>" alt="" />
				<?php endif; // end check for featured image or standard header ?>
			<?php endif; // end check for removed header image ?>


<?php if ( is_home() || is_front_page() ) {
			// Using conditionals to display rotator on Home page only:
			// http://www.themelab.com/2008/04/14/the-ultimate-guide-to-wordpress-conditional-tags/
			do_action('wp_rotator'); // Adds WP Rotator to header to make images rotate. Responsive (desktop, tablet, smart phone) rotating images provided via Flex Slider for WP Rotator.
			} ?>

What I’m running:

0 thoughts on “WP Twenty Eleven – Header Image Only On Home Page”

  1. Pingback: WP Twenty Eleven – Eliminare immagine testata nelle pagine | Appunti WP

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top