skip to Main Content

Looking for help in getting my wordpress theme to display header image on all pages and not just the home page as it currently does. All pages use get_header php command and the header.php contains the following code:

<?php
/**
 * The header for our theme
 *
 * This is the template that displays all of the <head> section and everything up until <div id="content">
 *
 * @link https://developer.wordpress.org/themes/basics/template-files/#template-partials
 *
 * @package Superb_Landingpage
 */

?>
<!doctype html>
<html <?php language_attributes(); ?>>
<head>
    <meta charset="<?php bloginfo( 'charset' ); ?>">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="profile" href="http://gmpg.org/xfn/11">

    <?php wp_head(); ?>
</head>

<body <?php body_class(); ?>>
        <?php wp_body_open(); ?>

    <div class="navigation-wrapper">
        
        <div class="site grid-container">
            <header id="masthead" class="site-header grid-x grid-padding-x">
                <div class="site-branding large-4 medium-10 small-9 cell">
                    <?php
                    the_custom_logo();
                    if ( is_front_page() && is_home() && is_page() ) :
                        ?>
                    <div class="logo-container">
                        <h1 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1>
                        <?php
                        else :
                            ?>
                        <div class="logo-container">
                            <h2 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h2>
                            <?php
                            endif;
                            $superb_landingpage_description = get_bloginfo( 'description', 'display' );
                            if ( $superb_landingpage_description || is_customize_preview() ) :
                                ?>
                            <p class="site-description"><?php echo $superb_landingpage_description; /* WPCS: xss ok. */ ?></p>
                        <?php endif; ?>
                    </div>  
                </div><!-- .site-branding -->

                <nav id="site-navigation" class="main-navigation large-8 medium-2 small-3 cell">

                    <?php
                    wp_nav_menu( array(
                        'theme_location' => 'menu-1',
                        'menu_id'        => 'primary-menu',
                        ) );
                        ?>
                    </nav><!-- #site-navigation -->
                </header><!-- #masthead -->
            </div>
        </div>

    <?php if ( get_header_image() ) : ?>
        <?php if ( is_front_page() ) : ?>

    <div class="content-wrap">
        <div class="bottom-header-wrapper">
            <img src="<?php echo esc_url(( get_header_image()) ); ?>" alt="<?php echo esc_attr(( get_bloginfo( 'title' )) ); ?>" />
        </div>
    </div>
        <?php endif; ?>

<?php endif; ?>
        <div id="page" class="site grid-container start-container-head">
            <a class="skip-link screen-reader-text" href="#content"><?php esc_html_e( 'Skip to content', 'superb-landingpage' ); ?></a>
            <div id="content" class="site-content grid-x grid-padding-x">

What do I add/remove to simply have the header display on all pages?

I’ve tried removing the if/else conditions in the header.php but wordpress keeps rolling back the edit claiming errors. Any help is greatly appreciated! Thank you.

2

Answers


  1. Try it

    <?php
    if ( is_home() ) {
        // This is a homepage
    } else {
        // This is not a homepage
    }
    ?>
    
    Login or Signup to reply.
  2. <?php
    if ( is_front_page() && is_home() ) {
        // This is a homepage
    } else {
        // This is not a homepage
    }
    ?>
    

    If this does not work try this

    <?php
    if ( is_front_page() ) {
        // This is a homepage
    } else {
        // This is not a homepage
    }
    ?>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search