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?
Thanks!
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?
Thanks!
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!
<?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[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...
Thanks!
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?
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
@alchymth,
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.
THANK YOU!
Blessings,
madisunanne.
<3
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
Brilliant!!
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[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 ?>
</a>
<?php endif; // end check for removed header image ?>So, @zink02, I just tried to do as you suggested and it didn't work. I deleted the && 1==2 and now when I try to access my site, I get an HTML Error 500, Internal Server Error! Help!! (I'm admittedly clueless when it comes to html code. Just starting out...) Can anyone help get me up and running again?? I have no idea what I just did.
RESOLVED!
THIS IS THE ORIGINAL CODE:
<?php
// 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( '/' ) ); ?>">
<?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[1] >= HEADER_IMAGE_WIDTH ) :
// Houston, we have a new header image!
echo get_header_image( $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 ?>
CHANGE FOR THIS CODE:
<?php
// 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( '/' ) ); ?>">
<img src="<?php header_image(); ?>" width="<?php echo HEADER_IMAGE_WIDTH; ?>" height="<?php echo HEADER_IMAGE_HEIGHT; ?>" alt="" />
</a>
<?php endif; // end check for removed header image ?>This topic has been closed to new replies.