• Resolved dajsco

    (@dajsco)


    Hi,

    I am trying to show the sidebar on product list page only. At the moment I have been using the following code which removes the sidebar from every page after the product category page which works great but not what I need.

    /**
    * Hide Sidebar
    */ 
    add_action( 'wp', 'woa_remove_sidebar_shop_page' );
    function woa_remove_sidebar_shop_page() {
    
    if ( is_product_category()) {
    
    remove_action( 'storefront_sidebar', 'storefront_get_sidebar', 10 );
    add_filter( 'body_class', 'woa_remove_sidebar_class_body', 10 );
    }
    }

    I want to be able to show the sidebar on the page which lists all the products in a specific category so I can add a product filter on the left column. I dont need a sidebar for the actual single product itself or for the category page the product list belongs to. I tried to add code to disable by tag_ID but this breaks my site.

    Hopefully this makes sense. Thanks for any help.

Viewing 1 replies (of 1 total)
  • Thread Starter dajsco

    (@dajsco)

    Ok got this to work by pure fluke. Just replace 'embroidered-products', 'vinyl-printed-products' with the name of your specific category and add the code to your child theme functions.php file.

    /**
    * Hide Sidebar
    */ 
    add_action( 'wp', 'woa_remove_sidebar_shop_page' );
    function woa_remove_sidebar_shop_page() {
    
    if ( is_product_category( array('embroidered-products', 'vinyl-printed-products')) || is_product()) {
    
    remove_action( 'storefront_sidebar', 'storefront_get_sidebar', 10 );
    add_filter( 'body_class', 'woa_remove_sidebar_class_body', 10 );
    }
    }
    • This reply was modified 5 years, 1 month ago by dajsco. Reason: add code tags
Viewing 1 replies (of 1 total)
  • The topic ‘Sidebar on product listing pages only’ is closed to new replies.