• I’ve been trying to use the code:

    function is_product_subcategory() {
    	$cat = get_query_var(‘product_cat’);
    	$category = get_category($cat);
    	$category->parent;
    	return ( $category->parent == ‘0’ ) ? false : true;
    }
    add_action( 'wp', 'remove_sidebar_parent_categories' );
     
    function remove_sidebar_parent_categories() {
    if ( !is_product_subcategory() ) {
    remove_action( 'woocommerce_sidebar', 'woocommerce_get_sidebar', 10 );
    }
    }

    but it didn’t work.
    Please help me with that issue.

    • This topic was modified 4 years, 6 months ago by liranrak.
    • This topic was modified 4 years, 6 months ago by liranrak.
    • This topic was modified 4 years, 6 months ago by liranrak.
    • This topic was modified 4 years, 6 months ago by liranrak.
    • This topic was modified 4 years, 6 months ago by liranrak.
    • This topic was modified 4 years, 6 months ago by liranrak.
  • The topic ‘Remove Woocommerce Sidebar in Categories not in subcategories’ is closed to new replies.