Skip to content

Commit 873cc69

Browse files
Ensure left sidebar is removed on single product pages.
1 parent 95eb4d9 commit 873cc69

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

app/integrations/woocommerce/template-functions.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -364,16 +364,19 @@ function bigbox_woocommerce_template_loop_stock() {
364364
};
365365

366366
/**
367-
* Remove tertiary sidebar on inner pages.
367+
* Manage sidebar locations and outputs.
368368
*
369369
* @since 1.0.0
370370
*/
371-
function bigbox_woocommerce_template_tertiary() {
372-
// Remove (filters) sidebar on single products.
373-
if ( is_singular( 'product' ) ) {
374-
remove_action( 'woocommerce_sidebar', 'woocommerce_get_sidebar' );
375-
// Add (tertiary) sidebar on archives.
376-
} else {
371+
function bigbox_woocommerce_template_sidebars() {
372+
// Remove default output.
373+
remove_action( 'woocommerce_sidebar', 'woocommerce_get_sidebar' );
374+
375+
if ( ! is_singular( 'product' ) ) {
376+
// Add sidebar before main column.
377+
add_action( 'woocommerce_before_main_content', 'woocommerce_get_sidebar', 0 );
378+
379+
// Output tertiary sidebar.
377380
add_action(
378381
'woocommerce_sidebar',
379382
function() {

app/integrations/woocommerce/template-hooks.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,8 @@
3535
* File: archive-product.php.
3636
*/
3737

38-
// Move sidebar before content for better tab order.
39-
remove_action( 'woocommerce_sidebar', 'woocommerce_get_sidebar' );
40-
add_action( 'woocommerce_before_main_content', 'woocommerce_get_sidebar', 0 );
38+
// Remove sidebar on single product pages.
39+
add_action( 'wp', 'bigbox_woocommerce_template_sidebars' );
4140

4241
// Replace outer content wrapper.
4342
remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper' );
@@ -104,9 +103,6 @@ function() {
104103
* File: content-single-product.php.
105104
*/
106105

107-
// Remove sidebar on single product pages.
108-
add_action( 'wp', 'bigbox_woocommerce_template_tertiary' );
109-
110106
// Filter product tabs.
111107
add_filter( 'woocommerce_product_tabs', 'bigbox_woocommerce_product_tabs', 20 );
112108

0 commit comments

Comments
 (0)