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 badges2 Answers
Reset to default 0Try 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
评论列表(0条)