How to remove header images from all pages except the home page? skeleton theme

The following one-liner removes regular header images:

! is_admin() && is_front_page() && add_filter( 'theme_mod_header_image', '__return_false' );

Usually, header images are saved and retrieved per Theme Modification API, which offers the same filter scheme "theme_mod_$name" for all theme data.

Update

I see now, the theme is using the post thumbnail as header images on single views:

<?php
// Check if this is a post or page, if it has a thumbnail, and if it exceeds defined HEADER_IMAGE_WIDTH
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!
$image_attr = array(
            'class' => "scale-with-grid",
            'alt'   => trim(strip_tags( $attachment->post_excerpt )),
            'title' => trim(strip_tags( $attachment->post_title ))
            );
echo '<div id="header_image" class="row sixteen columns">'.get_the_post_thumbnail( $post->ID, array("HEADER_IMAGE_WIDTH","HEADER_IMAGE_HEIGHT"), $image_attr ).'</div>';
elseif ( get_header_image() ) : ?>
    <div id="header_image" class="row sixteen columns"><img class="scale-with-grid round" src="https://wordpress.stackexchange.com/questions/63932/<?php header_image(); ?>" alt="" /></div>
<?php endif; ?> 

You have to remove that code in your child theme and replace it with:

if ( is_front_page() && get_header_image() )
{ 
?>
<div id="header_image" class="row sixteen columns">
    <img class="scale-with-grid round" src="https://wordpress.stackexchange.com/questions/63932/<?php header_image(); ?>" alt="" />
</div>
<?php 
} 

Leave a Comment