WordPress.org

Ready to get started?Download WordPress

Forums

Pilcrow
[resolved] Remove header image from subpages (3 posts)

  1. jseth
    Member
    Posted 1 year ago #

    I would like to have the header image only display on the home page. I do not see how to do this in the header.php file. Thank you.

  2. ricoh
    Member
    Posted 1 year ago #

    In the header.php look for the following code

    elseif ( get_header_image() ) : ?>
      <img src="<?php header_image(); ?>" width="<?php echo HEADER_IMAGE_WIDTH; ?>" height="<?php echo HEADER_IMAGE_HEIGHT; ?>" alt="" />
    <?php endif; ?>

    And change to the following:

    elseif ( get_header_image() ) : ?>
        <?php if ( is_home() || is_front_page() ) : ?>
          <img src="<?php header_image(); ?>" width="<?php echo HEADER_IMAGE_WIDTH; ?>" height="<?php echo HEADER_IMAGE_HEIGHT; ?>" alt="" />
        <?php endif; ?>
    <?php endif; ?>

    Remember always create a child theme first before making the aforementioned changes

  3. jseth
    Member
    Posted 1 year ago #

    Thank you for your reply! As I was waiting for a response, I did find that very solution! Under <div id="pic"> I inserted <?php if( is_home () || is_front_page() ) :?> then inserted <?php endif;?> directly before the </div><!-- #pic --> line, and the header image disappeared on all pages except the home page.

    And yes, I have created a child theme. Thank you again.

Topic Closed

This topic has been closed to new replies.

About this Theme

About this Topic