doutuo7126 2014-12-03 12:09
浏览 60
已采纳

仅删除商店/首页上的woocommerce侧栏

I'm building a site based on TwentyTwelve (child theme) and I'm using woocommerce. On my shop page (is also the sites frontpage) I want to remove the sidebar.

I came up with this code:

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

It works but it removes the sidebar on ALL woo pages (except the cart and checkout page) and it should be on the shop / frontpage (and searchresults for that matter)

Bottom line: I can't get my conditional statement right. Please help. Because I'm a bit of a newbie, keep it simple please. Thanks in advance.

  • 写回答

1条回答 默认 最新

  • duan47676379 2014-12-03 12:15
    关注

    Could you use css rather than php? if you target the body class of the front page like this:

    body.frontpage .sidebar{
       display:none;
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题