Reputation: 513
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.
Upvotes: 0
Views: 2291
Reputation: 148
Could you use css rather than php? if you target the body class of the front page like this:
body.frontpage .sidebar{
display:none;
}
Upvotes: 2