• Resolved SteveFromAus

    (@stevefromaus)


    Hi all,

    I am using the Twenty Sixteen them and wish to only have the header image on the home page. I have tried most of the solutions in the forum but none seem to work.

    Would someone be able to help? I would rather do it with css rather than editing the header.php file. I am using a child theme, but there is no header.php file in my child theme directory.

    My site is castleimages.net.au

    Regards,

    Steve

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi SteveFromAus

    If you have already created child theme then you need to copy and paste header.php file from main theme’s folder to child theme’s folder.
    Now find and replace below code in that header.php file in child theme folder.

    <?php if ( get_header_image() ) : ?>
    				<?php
    					/**
    					 * Filter the default twentysixteen custom header sizes attribute.
    					 *
    					 * @since Twenty Sixteen 1.0
    					 *
    					 * @param string $custom_header_sizes sizes attribute
    					 * for Custom Header. Default '(max-width: 709px) 85vw,
    					 * (max-width: 909px) 81vw, (max-width: 1362px) 88vw, 1200px'.
    					 */
    					$custom_header_sizes = apply_filters( 'twentysixteen_custom_header_sizes', '(max-width: 709px) 85vw, (max-width: 909px) 81vw, (max-width: 1362px) 88vw, 1200px' );
    				?>
    				<?php
    					if(is_front_page()){?>
    						<div class="header-image">
    							<a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home">
    								<img src="<?php header_image(); ?>" srcset="<?php echo esc_attr( wp_get_attachment_image_srcset( get_custom_header()->attachment_id ) ); ?>" sizes="<?php echo esc_attr( $custom_header_sizes ); ?>" width="<?php echo esc_attr( get_custom_header()->width ); ?>" height="<?php echo esc_attr( get_custom_header()->height ); ?>" alt="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>">
    							</a>
    						</div>
    
    					<?php
    
    					}
    				?>
    
    			<?php endif; // End header image check. ?>

    Hope this will help to resolve your issue.
    Let us know if any confusion.

    Best Regards!!!

    Thread Starter SteveFromAus

    (@stevefromaus)

    Thanks, that did the trick!

    WEN Solutions, I just wanted to that your code for removing all of the images from every page except the Home page worked great. I am not a beginner but I updated from 2013 to 2016 and that is one thing I do not like about 2016, it is annoying. It is like going to look at a new house and once you see it then you want to get inside and take a look around. It takes more time to render header images and it is redundant. This is my third website using WP and have always been in a hurry because it is for my business and this time I had more time and learned about creating a child folder which eliminates potential problems with future updates.
    I am not a beginner and I am sure there are some experts in WordPress but it is like some of the 3D design programs I have used, there are more ways to do something and I am weak on css & php coding so now that I got my site completed I will read up on css and php because it does make a difference, better than loading your install up with plugins that do not work.
    Thanks for a good post,
    Larry Harrison

    yes

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Remove header image from all pages other than home’ is closed to new replies.