Created
May 19, 2020 02:36
-
-
Save premanshup/2f7cb99f8d54a430fa7fd885372743ad to your computer and use it in GitHub Desktop.
If no widget present in Astra Theme, remove the sidebar for WooCommerce archive pages. ( Shop, Product Taxonomy, Checkout, Cart, Account Page ) - Add this code in child theem.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| add_action( 'wp', 'astra_woo_sidebar_layout' ); | |
| function astra_woo_sidebar_layout() { | |
| if ( is_shop() || is_product_taxonomy() || is_checkout() || is_cart() || is_account_page() ) { | |
| add_filter( 'astra_page_layout', 'astra_page_layout_woo_no_sidebar', 100 ); | |
| } | |
| } | |
| function astra_page_layout_woo_no_sidebar( $sidebar_layout ) { | |
| $sidebar = apply_filters( 'astra_get_sidebar', 'sidebar-1' ); | |
| $all_sidebars = wp_get_sidebars_widgets(); | |
| foreach ($all_sidebars as $id => $sidebar ) { | |
| if( count( $sidebar ) === 0 && 'astra-woo-shop-sidebar' === $id ) { | |
| // Enable no sidebar layout. | |
| $sidebar_layout = 'no-sidebar'; | |
| } | |
| } | |
| return $sidebar_layout; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment