0

I would like to change one thing on my wordpress custom template - there are big image sliders used throughout the site except on the contact us, checkout and my account pages. The blog page was added after these were created, so in the header.php file this is what is currently there to exclude the slider images (or include) from the necessary pages:

if(!is_cart() && !is_checkout() && !is_account_page()) :
            if(is_page( 'contact-us' )):
                get_template_part( 'template-parts/header/header', 'map' ); 
            else:
                get_template_part( 'template-parts/header/header', 'slider' ); 
            endif;
        endif;

I added this to the code and it doesn't work:

if(**!is_blog() &&** !is_cart() && !is_checkout() && !is_account_page()) :
            if(is_page( 'contact-us' )):
                get_template_part( 'template-parts/header/header', 'map' ); 
            else:
                get_template_part( 'template-parts/header/header', 'slider' ); 
            endif;
        endif;  

It seemed to me that is all I would need to do but clearly I need some assistance.

0

Try this:

if ( !is_home() && !is_cart() && !is_checkout() && !is_account_page() ) :
    if ( is_page( 'contact-us' ) ):
        get_template_part( 'template-parts/header/header', 'map' ); 
    else:
        get_template_part( 'template-parts/header/header', 'slider' );
    endif;
endif;

is_home() will return true if the current page/query is for the blog homepage, otherwise it returns false.

You can read up about is_home() on the WordPress Developer page.

0

You can create a separate header.php file and call it something like header-light.php. in your get_header() call you pass the one you want. Like this:

get_header( 'light' );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.