Removing sidebar from single product page in FACTORY wp theme

I want to disable the sidebar completely from WooCommerce single product page, and make the page full width.

I have read and tried each and every document available but to nothing is available.

Read More

Steps:

  1. Copied the following code to functions.php

    function remove_sidebar_shop() {
        if ( is_product() ) {
            remove_action('woocommerce_sidebar','woocommerce_get_sidebar');
            echo("Test if");
        }
    
        else {
            echo("Test else");
        }
    }
    
    add_action('get_header','remove_sidebar_shop');
    

(the echo parts were for debugging)

  1. Commented the line do_action('woocommerce_sidebar'); in archive-product.php after copying it to my-theme/woocommerce.

  2. Commented the line do_action('woocommerce_sidebar'); in single-product.php after copying it to my-theme/woocommerce.

  3. Commented the whole sidebar.php file.

But nothing seems to work.

Related posts

Leave a Reply

1 comment

  1. After hours of head scratching, found a solution myself,

    In the overridden single-product.php, till now i was commenting the line

    do_action('woocommerce_sidebar');
    

    But instead, commenting this line

    do_action('woocommerce_after_main_content');
    

    did the trick.

    Cheers….