【发布时间】:2015-08-28 12:28:49
【问题描述】:
下面的 php 代码在第二深度时从页面中删除侧边栏,但当此函数删除同一页面上的侧边栏时,我想将以下 div 的类更改为“全角”,因为我的页面有侧栏相同的 css 适用于没有侧边栏且页面为半宽的页面。
function so_32165017_conditionally_remove_sidebar(){
if( is_product_category()){
$t_id = get_queried_object()->term_id;
if( so_32165017_get_product_cat_depth( $t_id ) < 2 ){
remove_action( 'woocommerce_sidebar', 'woocommerce_get_sidebar', 10 );
// could be theme specific ex: Storefront
remove_action( 'storefront_sidebar', 'storefront_get_sidebar', 10 );
}
}
}
add_action( 'woocommerce_before_main_content', 'so_32165017_conditionally_remove_sidebar' );
HTML:
发件人:
<div id="primary" class="content-area">
收件人:
<div id="primary" class="fullwidth">
【问题讨论】: