Support » Plugin: WP Header Images » Default Header Image shown under Image selected with WHI

  • Resolved Michiel Koekkoek

    (@michiel-koekkoek)


    hello Fahad, I installed WHI and selected images for a few pages. For those pages the selected image is shown but immediately after the ‘default’ header image is shown. Pages with no selected images show only the default header image. I suppose i wrongly inserted the code line <?php do_shortcode(‘[WP_HEADER_IMAGES]’); ?> in the wrong place in header.php of my theme Colinear. The code is as follows:

    <?php
    /**
     * The header for our theme.
     *
     * Displays all of the <head> section and everything up till <div id="content">
     *
     * @package Colinear
     */
    
    ?><!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">
    <link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>">
    
    <?php wp_head(); ?>
    </head>
    
    <body <?php body_class(); ?>>
    <div id="page" class="hfeed site">
    	<a class="skip-link screen-reader-text" href="#content"><?php esc_html_e( 'Skip to content', 'colinear' ); ?></a>
    
    	<header id="masthead" class="site-header" role="banner">
    		<div class="site-branding">
    			<?php colinear_the_site_logo(); ?>
    
    			<?php
    				if ( is_front_page() && is_home() ) : ?>
    					<h1 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1>
    				<?php else : ?>
    					<p class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></p>
    				<?php endif;
    
    				$description = get_bloginfo( 'description', 'display' );
    				if ( $description || is_customize_preview() ) : ?>
    					<p class="site-description"><?php echo $description; ?></p>
    				<?php endif;
    			?>
    		</div><!-- .site-branding -->
    
    		<?php if ( has_nav_menu( 'primary' ) ) : ?>
    		<nav id="site-navigation" class="main-navigation" role="navigation">
    			<button class="menu-toggle" aria-controls="primary-menu" aria-expanded="false"><span class="screen-reader-text"><?php esc_html_e( 'Primary Menu', 'colinear' ); ?></span></button>
    			<?php
    				// Primary navigation menu.
    				wp_nav_menu( array(
    					'theme_location' => 'primary',
    					'menu_id'        => 'primary-menu',
    				) );
    			?>
    		</nav><!-- #site-navigation -->
    		<?php endif; ?>
    
    		<?php if ( get_header_image() ) : ?>
    		<?php do_shortcode('[WP_HEADER_IMAGES]'); ?>
    		<div class="header-image">
    			<a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home">
    				<img src="<?php header_image(); ?>" width="<?php echo esc_attr( get_custom_header()->width ); ?>" height="<?php echo esc_attr( get_custom_header()->height ); ?>" alt="">
    			</a>
    		</div><!-- .header-image -->
    		<?php endif; // End header image check. ?>
    	</header><!-- #masthead -->
    
    	<div id="content" class="site-content">

    Could you be so kind to have a look?
    Thanks in advance and greetings,
    Michiel Koekkoek

Viewing 11 replies - 1 through 11 (of 11 total)
  • @michiel-koekkoek please provide the screenshot of your settings page.

    Is shown header on your pages WPHI header or theme’s header?

    Thread Starter Michiel Koekkoek

    (@michiel-koekkoek)

    hello Danial,
    Which settings do you mean?
    On pages with WPHI header defined this WPHI is shown immediately followed by theme header. On other pages only theme header is shown.
    Kind regards,
    Michiel

    Please provide the screenshot of Developers tab on settings page.

    Thread Starter Michiel Koekkoek

    (@michiel-koekkoek)

    stupid question: how to attach image?

    Plugin Author Fahad Mahmood

    (@fahadmahmood)

    @michiel-koekkoek please observe the following code and keep the bold one and remove the italic part.

    <?php if ( get_header_image() ) : ?>
    <?php do_shortcode(‘[WP_HEADER_IMAGES]’); ?>
    <div class=”header-image”>” rel=”home”>
    ” width=”<?php echo esc_attr( get_custom_header()->width ); ?>” height=”<?php echo esc_attr( get_custom_header()->height ); ?>” alt=””>

    </div>
    <!– .header-image –>
    <?php endif; // End header image check. ?>

    Thread Starter Michiel Koekkoek

    (@michiel-koekkoek)

    Thanks so much Fahad, but now pages without WPHI defined image do not have the theme image. Should I give every page a WPHI image?
    Kind greetings,
    Michiel

    Plugin Author Fahad Mahmood

    (@fahadmahmood)

    Correct, use either WPHI or your theme image. If you are trying to use these together then you have to implement if conditions accordingly.

    Thread Starter Michiel Koekkoek

    (@michiel-koekkoek)

    Thanks, Fahad. Do you maybe have a coding example?

    Plugin Author Fahad Mahmood

    (@fahadmahmood)

    Coding example will vary case to case, what is your requirement?

    On which pages you need the default theme’s header image?

    Thread Starter Michiel Koekkoek

    (@michiel-koekkoek)

    hello Fahad, i have not that many pages (10 at most) so i will give every page its own picture also some will have the same picture which will be the one i used as default.
    Thanks again for your help. Your plugin is great.
    Kind regards,
    Michiel

    Plugin Author Fahad Mahmood

    (@fahadmahmood)

    @michiel-koekkoek I was asking because every page can have a different condition. For example you need default image for home page. So condition will be the following.

    <?php if (is_home() && get_header_image() ) : ?>
    <div class="header-image">
    			<a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home">
    				<img src="<?php header_image(); ?>" width="<?php echo esc_attr( get_custom_header()->width ); ?>" height="<?php echo esc_attr( get_custom_header()->height ); ?>" alt="">
    			</a>
    		</div>
    <?php else: ?>
    <div class="header-image">
    <?php do_shortcode('[WP_HEADER_IMAGES]'); ?>
    </div>
    <?php endif;  ?>
    

    Please try and let me know if it resolves your problem?

Viewing 11 replies - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.