Black Friday Sale! Get up to $30 off GP Premium! Learn more โž

[Resolved] Help with sidebars

Home Forums Support [Resolved] Help with sidebars

Home Forums Support Help with sidebars

  • This topic has 5 replies, 2 voices, and was last updated 5 years ago by Tom.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #242249
    MaksymPS

    Hello Tom,

    Is there any way to make on Shop page left-sidebar and on the Product page right-sidebar?

    I have the next situation:
    I installed WooCommerce Product Filter and pasted your code from this post to functions.php. As a result I have a product filter in left-sidebar. Very good. But, I need when I go to Product Page there must be right-sidebar.

    I tried to find something in comments of this plugin, but they write next things:

    The default product filter shouldnโ€™t be displaying on your single product pages, unless you installed the filter using a custom action or have it as a widget in the sidebar, which you also display on single product pages (in which case you just need to set a different sidebar, without the widget, to your product pages).

    However, overrides on single product pages are not supported. You can only override product archive pages.

    My global option is “Content: no sidebars” and my products option (sidebar layout) is “Global Layout Settings”

    Could you help me in this case, please?

    Thanks in advance!

    #242278
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    By “Product” page I assume you mean the single product? If so, you could try something like this:

    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() && ! is_product() )
     	 	return 'left-sidebar';
    
     	// If we're viewing a single product
     	if ( is_product() )
     	 	return 'right-sidebar';
    
     	// Or else, set the regular layout
     	return $layout;
    
     }

    Hope this helps ๐Ÿ™‚

    #242367
    MaksymPS

    Hello Tom,
    Thanks for your answer!

    But it didn’t help ๐Ÿ™
    Could you visit my site and take a look what is happening: http://vetlikar.com/shop/

    Now, at the present moment, I have this code in functions.php

    add_filter( 'generate_sidebar_layout','generate_custom_woocommerce_sidebar_layout' );
    function generate_custom_woocommerce_sidebar_layout( $layout )
    {
    	
     	if ( is_woocommerce() )
     	 	return 'left-sidebar'; 	
    
     	if ( is_product() )
     	 	return 'right-sidebar';
    
     }

    And can’t understand why it does not as it should be (left-sidebar shop, right-sidebar product page)

    Thanks in advance!

    #242385
    Tom
    Lead Developer
    Lead Developer

    I just adjusted the function – can you give it another shot?

    #242436
    MaksymPS

    AWESOME!

    You are the best! Thanks a lot!
    I will buy you a coffee ๐Ÿ™‚

    #242504
    Tom
    Lead Developer
    Lead Developer
Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.