[Resolved] Settings to turn off Sidebar on Woocommerce's page Shop

Home Forums Support [Resolved] Settings to turn off Sidebar on Woocommerce's page Shop

Home Forums Support Settings to turn off Sidebar on Woocommerce's page Shop

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #207786
    Dmitry Bychenko

    hi guys,

    im trying to turn off Sidebar on Woocommerce’s page Shop.

    I use the code

    add_filter( ‘generate_sidebar_layout’,’generate_custom_woocommerce_sidebar_layout’ );
    function generate_custom_woocommerce_sidebar_layout( $layout )
    {
    // If we are on a woocommerce page, set the sidebar
    if ( is_woocommerce() )
    return ‘no-sidebar’;

    // Or else, set the regular layout
    return $layout;

    }

    as it is said on https://generatepress.com/knowledgebase/choosing-sidebar-layouts/#sidebar-filter
    but Sidebar is still there.
    What im doing wrong, how to turn it off?

    • This topic was modified 7 years, 9 months ago by Dmitry Bychenko.
    #207789
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    No need to add “Shop” in the is_woocommerce() call.

    Your code would be:

    add_filter( 'generate_sidebar_layout','generate_custom_woocommerce_sidebar_layout' );
    function generate_custom_woocommerce_sidebar_layout( $layout )
    {
     	// If we are on a woocommerce page, set the sidebar
     	if ( is_woocommerce() )
     	 	return 'no-sidebar';
    
     	// Or else, set the regular layout
     	return $layout;
    
     }
    #207799
    Dmitry Bychenko

    yes, i just tried to write Shop because

    add_filter( ‘generate_sidebar_layout’,’generate_custom_woocommerce_sidebar_layout’ );
    function generate_custom_woocommerce_sidebar_layout( $layout )
    {
    // If we are on a woocommerce page, set the sidebar
    if ( is_woocommerce() )
    return ‘no-sidebar’;

    // Or else, set the regular layout
    return $layout;

    }

    doesnt work. Sidebar is still there

    #207800
    Tom
    Lead Developer
    Lead Developer

    If that’s not working, it means is_woocommerce() isn’t true.

    Try the metabox on the page instead: https://generatepress.com/knowledgebase/choosing-sidebar-layouts/#metabox

    #207801
    Dmitry Bychenko

    that metabox doesnt work too.

    what means “is_woocommerce() isn’t true” ?

    i’ve installed normal woocommerce plugin from wordpress’es repository

    #207802
    Tom
    Lead Developer
    Lead Developer

    That’s a conditional in WooCommerce, it return either true or false depending on if you’re on a woocommerce page.

    If that code isn’t working, it means it’s returning false.

    Can you link me to the page you’re trying to change the sidebar on?

    #207803
    Dmitry Bychenko
    #207805
    Tom
    Lead Developer
    Lead Developer

    Hmm, that code should work.

    How/where are you adding the code in this post?: https://generatepress.com/forums/topic/settings-to-turn-off-sidebar-on-woocommerces-page-shop/#post-207789

    #207816
    Dmitry Bychenko

    i put this code in Shop Page’s metabox

    https://www.dropbox.com/s/emufz2ugtvhvhrv/Shop_woo.jpg?dl=0

    #207817
    Tom
    Lead Developer
    Lead Developer

    Ah that’s the problem, you need to add it like this: https://generatepress.com/knowledgebase/adding-php-functions/

    #207822
    Dmitry Bychenko

    yeh, php is not css… 🙂

    it’s working with simple php

    thanks!

    #207828
    Tom
    Lead Developer
    Lead Developer

    You’re welcome 🙂

Viewing 12 posts - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.