Support » Theme: Forever » How to see the header image only in the homepage

  • Hello,
    I use Forever theme. I’d like to know if it’s possible to see the header image only in homepage and not in all pages of my website. If yes how can I do?
    Thanks.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi Giugot87!

    Yes! This is possible to do with the is_front_page() function, which checks if the page you’re on, is the homepage. In order to remove the header image on the other pages you need to edit the masthead.php file inside the “forever” theme folder.

    Look for this code:

    <a class="custom-header" href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home">
    			<img class="custom-header-image" src="<?php header_image(); ?>" width="<?php echo get_custom_header()->width; ?>" height="<?php echo get_custom_header()->height; ?>" alt="" />
    		</a>

    This is the header image you want to remove.

    Add this in front of it:

    <?php if (is_front_page()) { ?>

    And this after:

    <?php } ?>

    That should check if you’re on the homepage and if you are, then display the image.

    Hope this helped you and solved your problem.

    Cheers!
    Øyvind Sæther
    Touchcoding

    Øyvind – thanks for helping out with this.

    In order to remove the header image on the other pages you need to edit the masthead.php file inside the “forever” theme folder.

    giugot87 – be careful not to edit the theme files directly, or all your changes will be lost every time you update the theme. If you’d like to use this method, be sure to create a child theme first, so your changes won’t be overwritten on theme update. Here are some guides in case you haven’t made one before:

    http://codex.wordpress.org/Child_Themes
    http://op111.net/53/
    http://vimeo.com/39023468

    If you prefer to use a CSS-only method, this should do it:

    .custom-header, .custom-header-image {
    	display: none;
    }
    .home .custom-header, .home .custom-header-image {
    	display: inherit;
    }

    Again, don’t edit your theme files directly, otherwise your changes will be overwritten whenever the theme is updated.

    An easy way to add custom CSS is to install the Jetpack plugin and activate the Custom CSS module. You’ll then add your custom CSS in the new stylesheet editor that’ll appear in your dashboard, under Appearance > Edit CSS.

    As alternatives, you could either install a standalone custom CSS plugin, or create a child theme.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to see the header image only in the homepage’ is closed to new replies.