admin管理员组文章数量:1279124
I am using this below code to remove woocommerce sidebar, from cart and single-product page.
function urun_sidebar_kaldir() {
if ( is_product() || is_cart() ) {
remove_action( 'woocommerce_sidebar', 'woocommerce_get_sidebar', 10 );
}
}
add_action( 'woocommerce_before_main_content', 'urun_sidebar_kaldir' );
It works in single-product page, but it doesn't work cart page.
I can't remove sidebar in cart page.
//Update
I am not using woocommerce.php in theme main folder.
And i have this templates in my theme.
wp-content/themes/{current-theme}/woocommerce/cart/cart.php
I created custom teplate for cart. And i removed get_sidebar(); but sidebar is still displaying in cart page.
wp-content/themes/{current-theme}/page-cart.php
wp-content/themes/{current-theme}/page-checkout.php
I am using this below code to remove woocommerce sidebar, from cart and single-product page.
function urun_sidebar_kaldir() {
if ( is_product() || is_cart() ) {
remove_action( 'woocommerce_sidebar', 'woocommerce_get_sidebar', 10 );
}
}
add_action( 'woocommerce_before_main_content', 'urun_sidebar_kaldir' );
It works in single-product page, but it doesn't work cart page.
I can't remove sidebar in cart page.
//Update
I am not using woocommerce.php in theme main folder.
And i have this templates in my theme.
wp-content/themes/{current-theme}/woocommerce/cart/cart.php
I created custom teplate for cart. And i removed get_sidebar(); but sidebar is still displaying in cart page.
wp-content/themes/{current-theme}/page-cart.php
wp-content/themes/{current-theme}/page-checkout.php
Share
Improve this question
edited Jun 9, 2018 at 10:01
wpdev
asked Jun 9, 2018 at 7:31
wpdevwpdev
5492 gold badges13 silver badges28 bronze badges
2 Answers
Reset to default 2First, most themes have multiple page templates you can choose from.
Please check:
- go to cart page (in wp-admin).
- See side metabox 'Page Attributes'.
- There you can set the page template, does it have something like 'full_width'?
You can also try a different hook, like wp_head
.
Example:
add_action( 'wp_head', 'urun_sidebar_kaldir' );
Let me know.
After checking the WOO cart template, i can't find a do_action( 'woocommerce_sidebar' )
.
It does exist in the singe-product.php template.
Are you certain the cart sidebar is generated by WooCommerce?
Add a full-width template to your theme:
Read this.
Then follow the steps i mentiod at the beginning of my answer.
For me it works with the following code, but I'm not sure if this is really viable and future proof.
function woo_remove_sidebar() {
if( ! is_product() or
! is_cart() or
! is_checkout() or
! is_account_page() )
{
remove_action( 'woocommerce_sidebar', 'woocommerce_get_sidebar', 10 );
}
}
add_filter( 'is_active_sidebar', 'woo_remove_sidebar' );
本文标签: Can39t remove woocommerce sidebar
版权声明:本文标题:Can't remove woocommerce sidebar 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741213111a2359521.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论