Blog template with different header to rest of site

I would like to change one thing on my wordpress custom template - there are big image sliders used throughout the site

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.

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.

Share Improve this question edited Oct 9, 2019 at 12:18 fuxia 107k39 gold badges255 silver badges459 bronze badges asked Oct 9, 2019 at 9:53 MarvynHMarvynH 34 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 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.

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' );

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745084002a4610295.html

相关推荐

  • Blog template with different header to rest of site

    I would like to change one thing on my wordpress custom template - there are big image sliders used throughout the site

    12小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信