Support » Themes and Templates » twenty eleven disable featured image in header

twenty eleven disable featured image in header

  • Hi, does anyone know how I can disable the featured image in the header in the twenty twelve theme? It doesn’t look like I can remove it from within header settings so is the only option to remove this from within header.php?

Viewing 15 replies - 1 through 15 (of 17 total)
  • Create a child theme where you copy header.php from Twenty Eleven. Then you remove the lines from header.php and can still enjoy all the other features in the parent theme. Check theme.fm/2011/07/how-to-create-a-child-theme-based-on-twenty-eleven-791/ for instructions.

    Thanks dogoodzilla,
    which lines do I have to remove from the header? I’m not a complete expert at php so sometimes I don’t quite get it right!

    					// Check if this is a post or page, if it has a thumbnail, and if it's a big one
    					if ( is_singular() && current_theme_supports( 'post-thumbnails' ) &&
    							has_post_thumbnail( $post->ID ) &&
    							( /* $src, $width, $height */ $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'post-thumbnail' ) ) &&
    							$image[1] >= HEADER_IMAGE_WIDTH ) :
    						// Houston, we have a new header image!
    						echo get_the_post_thumbnail( $post->ID );
    					elseif ( get_header_image() ) : ?>

    But I must’ve got that wrong as the header wouldn’t load anymore…

    Have you tried disabling the header inage using the setting for it under /wp-admin/themes.php?page=custom-header ?

    I did that for a demo site and it removed the header image from Twenty Eleven. No need to create a child theme, even though child theme is preferred when making custom settings.

    I’ve uploaded a custom header so I can’t remove it completely, I just don’t want the featured images to override the header… which is why I presume I need to alter the code. Or is there another way you know of?

    Here’s what to do:
    1) create a child theme for twenty-eleven
    2) in the header.php of your child theme, go to line 92 and comment out this line as shown (two slashes in front):
    //echo get_the_post_thumbnail( $post->ID, 'post-thumbnail' );
    3) Now you can add featured images to your posts, and they won’t show in your header.

    I second dogoodzilla’s suggestion to set up a child theme with a good tutorial like this one at theme.fm

    Hope this helps!

    yes, it works 100%. you super!

    I’ve tried to remove line 92 from my child theme’s header.php as bluejpro noted but when I select a featured image for a post, it STILL shows up as the custom header. I’ve also tried this and it doesn’t work.

    Any help is much appreciated!

    So more help here please…

    I have followed bluejpro’s instructions and they work by removing the featured image, but now there is no header whatsoever.

    How do I edit the header.php to keep the same header static through all pages/posts?

    Moderator Michael


    Forum Moderator

    based on wp3.4 and Twenty Eleven 1.4
    (i.e. will not work in a WordPress version less than wp3.4)

    make sure to create a child theme to work with – http://codex.wordpress.org/Child_Themes

    edit header.php in your child theme, and change the corresponding section to:


    Thanks so much, works 100%

    Thanks so much, works good in NomNom Child Them 2.0


    I’ve spent quite a few days finding out how to keep my header static in single-post pages w/o the featured image popping up there. I’ve tried a bunch of things, & nothing worked except your fix above.



    I found a quicker fix for this problem if anyone is interested.

    In header.php go to line 95 where there is a long if statement to check if the featured thumbnail is big enough to be a header image.

    Simply add a condition into the if statement that is always false.

    I used: && 1==2

    This makes the page think the featured image is never acceptable to be used as a header, so it just keeps your original header image.

    @ zink02

    I wanted to keep the header so I commented out the if/then condition for the featured image:

    					// 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 ?>
Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘twenty eleven disable featured image in header’ is closed to new replies.