我正在 Build 一个基于TwentyTwelve(儿童主题)的网站,我正在使用woocommerce . 在我的商店页面(也是网站首页)我想删除侧边栏 .
我想出了这段代码:
if(is_front_page() ){
remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10);
remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10);
remove_action( 'woocommerce_sidebar', 'woocommerce_get_sidebar', 10 );
add_action('woocommerce_before_main_content', 'twentytwelve_child_wrapper_start', 10);
add_action('woocommerce_after_main_content', 'twentytwelve_child_wrapper_end', 10);
function twentytwelve_child_wrapper_start() {
echo '<div id="shop">';
}
function twentytwelve_child_wrapper_end() {
echo '</div>';
}
}
它可以工作,但它删除所有woo页面上的侧边栏(除了购物车和结帐页面),它应该在商店/首页上(和搜索结果相关)
一句话:我无法得到正确的条件陈述 . 请帮忙 . 因为我是一个新手,请保持简单 . 提前致谢 .
1 回答
你能用css而不是php吗?如果你像这样定位首页的body类: