• In my header.php file I currently have the following code related to displaying my header image

    <div class="clear"></div>
    <div class="head-img">
      <div class="tagline"><?php bloginfo('description'); ?></div>
    
      <?php $t_custom_background = get_option( "nattywp_custom_header" );
        if ($t_custom_background != '') { ?>
        <img src="<?php echo $t_custom_background; ?>" alt="Header image" border="0" />
       <?php } elseif (!isset($t_main_img) || $t_main_img == 'no' || $t_main_img == 'header2.jpg' ) {  ?>
        <img src="<?php echo get_template_directory_uri(); ?>/images/header/headers.jpg" alt="Header image" border="0" />
       <?php } else { ?>
        <img src="<?php echo get_template_directory_uri(); ?>/images/header/<?php echo t_get_option( "t_main_img" ); ?>" alt="Header image" border="0" />
      <?php } ?>

    I know adding this php code elimates the image from all pages but the front page

    <?php if( is_home() || is_front_page() ) : ?>
    
    YOUR CODE HERE
    
    <?php endif; ?>

    However I would like to have the front page display no header image, and all other pages display the image as is.

    My wordpress site can be found here: http://www.solarintsys.com

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator keesiemeijer

    (@keesiemeijer)

    try

    <?php if( is_home() || is_front_page() ) : ?>
    <!-- no header code -->
    <?php else : ?>
    <!-- header code -->
    <?php endif; ?>

    or

    <?php if( !is_home() || !is_front_page() ) : ?>
    YOUR CODE HERE
    <?php endif; ?>

    the ! means not.

    Hi, this will only run the custom background code section on pages that are not homepage and not the front page.

    <?php
    if( !is_home() && !is_front_page() ) :
      $t_custom_background = get_option( "nattywp_custom_header" );
      if ($t_custom_background != '') {
    ?>
      <img src="<?php echo $t_custom_background; ?>" alt="Header image" border="0" />
    <?php
      } elseif (!isset($t_main_img) || $t_main_img == 'no' || $t_main_img == 'header2.jpg' ) {
    ?>
      <img src="<?php echo get_template_directory_uri(); ?>/images/header/headers.jpg" alt="Header image" border="0" />
    <?php
      } else {
    ?>
      <img src="<?php echo get_template_directory_uri(); ?>/images/header/<?php echo t_get_option( "t_main_img" ); ?>" alt="Header image" border="0" />
    <?php
      }
    endif;
    ?>

    Thread Starter Samer Sultan

    (@samersultan1)

    Thanks a lot for your help,

    For some reason it seems not to work; is there an alternative PHP or CSS code for removing the header image from the front page?

    Thread Starter Samer Sultan

    (@samersultan1)

    Spoke a bit early, thanks a lot guys I got it to work!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Modify "IF" statement to exclude front page’ is closed to new replies.