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.
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!
<?php // 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 >= 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
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!
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?
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
ifstatement 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.
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.
I wanted to keep the header so I commented out the if/then condition for the featured image:
<?php // 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 >= 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 ?> </a> <?php endif; // end check for removed header image ?>
- The topic ‘twenty eleven disable featured image in header’ is closed to new replies.