WordPress.org

Forums

Formation
[resolved] get_header(); (4 posts)

  1. billy1983
    Member
    Posted 11 months ago #

    Hi,
    i am trying to make the header image only display on the homepage. so what i have done is to create a duplicate the header.php file and i have created a new template also. what i am struggling with is the get_header(); function call at the top of the php page. can someone tell me what javascript file the get_header() function is in so i can duplicate it. or tell me how i can do it another way.
    Many thanks
    Billy

  2. Samuel Elh
    Member
    Posted 11 months ago #

    use names, and call the homepage header using it's name :
    get_header( $name );
    read about it in codex
    i tried to apply it but unfortunately my theme does not support custom headers ..

  3. linux4me2
    Member
    Posted 10 months ago #

    It sounds like you already created a child theme? If so, just copy the header.php from the parent theme's folder to your child theme's folder.

    Find this code in the header.php file:

    <div class="header-image">
    	<?php $header_image = get_header_image();
    		if ( ! empty( $header_image ) ) { ?>
    			<a href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home">
    				<img src="<?php header_image(); ?>" width="<?php echo get_custom_header()->width; ?>" height="<?php echo get_custom_header()->height; ?>" alt="" />
    			</a>
    		<?php } // if ( ! empty( $header_image ) ) ?>
    	</div>

    and replace it with:

    <div class="header-image">
    	<?php
    		if (is_front_page()) {
    			$header_image = get_header_image();
    			if ( ! empty( $header_image ) ) {
    			?>
    				<a href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home">
    					<img src="<?php header_image(); ?>" width="<?php echo get_custom_header()->width; ?>" height="<?php echo get_custom_header()->height; ?>" alt="" />
    				</a>
    			<?php
    			}
    		}
    	?>
    	</div>

    You don't need to worry about the get_header() function. It's not involved with the header image.

  4. Template Express
    Member
    Theme Author

    Posted 10 months ago #

    thanks linux that should indeed do the trick

Reply

You must log in to post.

About this Theme

About this Topic