• Hello

    i am using twentytwelve – child theme right now
    and codes in my functions.php file under child theme looks like the below (because i was trying to set the dimensions of header image)

    right now, i would like to remove the header image from travelmolecule.com/gallery. this is the only page i want the header image to be removed, other pages should still show the header image

    how do i do that?

    I tried various solutions from what i found online, insert the code into the functions.php file under child theme but doesnt work 🙁

    please help!

    ——————————-
    CURRENT CODE IN FUNCTIONS.PHP
    ——————————-

    <?php
    
    /* This function will run after the parents functions.php */
    add_action( 'after_setup_theme', 'post_theme_setup' );
    
    if ( !function_exists( 'post_theme_setup' ) ):
    
    function post_theme_setup() {
       /* Code goes here! */
    
       add_filter( 'twentytwelve_header_image_width', 'my_header_width' );
       add_filter( 'twentytwelve_header_image_height', 'my_header_height' );
       function my_header_width($width) {
       	$width = 1200;
    	return $width;
       }
       function my_header_height($height) {
    	$height = 400;
    	return $height;
       }
    
    endif;

    [Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum’s parser.]

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter wpnoob2014

    (@wpnoob2014)

    sorry, miss one closing bracket
    correct code as it exist now is the following:

    <?php
    
    /* This function will run after the parents functions.php */
    add_action( 'after_setup_theme', 'post_theme_setup' );
    
    if ( !function_exists( 'post_theme_setup' ) ):
    
    function post_theme_setup() {
       /* Code goes here! */
    
       add_filter( 'twentytwelve_header_image_width', 'my_header_width' );
       add_filter( 'twentytwelve_header_image_height', 'my_header_height' );
       function my_header_width($width) {
       	$width = 1200;
    	return $width;
       }
       function my_header_height($height) {
    	$height = 400;
    	return $height;
       }
    
    }
    endif;

    [Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum’s parser.]

    Where is the output of the header located? I’de say you can add the following if-statement around that.

    if(! is_page('gallery')){ // your header image output goes here }

    Thread Starter wpnoob2014

    (@wpnoob2014)

    thanks Jeffreyvr. but sorry, what is “output of the header”? where do i find it? .css file? and what code phrase?

    need more explanation here… 100% newbie.

    Thread Starter wpnoob2014

    (@wpnoob2014)

    sorry 🙁 still need help. i still cant get this to work on my website
    i dont know whether i am supposed to modify in .css file, .php file, or customheader.php file

    but whatever i tried now doesnt work

    somone?

    Thread Starter wpnoob2014

    (@wpnoob2014)

    <?php if( !is_page( 'Gallery' )) : ?>
    
    		<?php if ( get_header_image() ) : ?>
    		<a href="<?php echo esc_url( home_url( '/' ) ); ?>"><img src="<?php header_image(); ?>" class="header-image" width="<?php echo get_custom_header()->width; ?>" height="<?php echo get_custom_header()->height; ?>" alt="" /></a>
    		<?php endif; ?>
    	</header><!-- #masthead -->
    
    	<div id="main" class="wrapper">
    
    <?php endif; ?>

    ok. i think i figured out, the above is what i have in header.php

    now my game plan change. i want to only have header image on ABOUT ME page only, the rest of them, I do not want the header image to appear.
    Can you please assist me in modifying the code?

    I tried the below but it didnt work – i am trying to say that i only want the ‘get header’ image code executed only if the page name is About me.

    <?php if( is_page( 'About me' )) : ?>
    
    		<?php if ( get_header_image() ) : ?>
    		<a href="<?php echo esc_url( home_url( '/' ) ); ?>"><img src="<?php header_image(); ?>" class="header-image" width="<?php echo get_custom_header()->width; ?>" height="<?php echo get_custom_header()->height; ?>" alt="" /></a>
    		<?php endif; ?>
    	</header><!-- #masthead -->
    
    	<div id="main" class="wrapper">
    
    <?php endif; ?>
    <?php if(is_page('About me')){ ?>
    
    		<?php if ( get_header_image() ) : ?>
    		<a href="<?php echo esc_url( home_url( '/' ) ); ?>"><img src="<?php header_image(); ?>" class="header-image" width="<?php echo get_custom_header()->width; ?>" height="<?php echo get_custom_header()->height; ?>" alt="" /></a>
    		<?php endif; ?>
    <?php } ?>
    	</header><!-- #masthead -->

    This must work. I’ve tested to be sure.

    Thread Starter wpnoob2014

    (@wpnoob2014)

    yes, work now, thanks!!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘how to remove header image from one page only?’ is closed to new replies.