- This topic has 5 replies, 2 voices, and was last updated 8 years, 4 months ago by
Tom.
-
AuthorPosts
-
November 6, 2016 at 4:51 pm #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!
November 6, 2016 at 8:40 pm #242278Tom
Lead DeveloperLead DeveloperHi 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 🙂
November 7, 2016 at 9:05 am #242367MaksymPS
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!
November 7, 2016 at 10:58 am #242385Tom
Lead DeveloperLead DeveloperI just adjusted the function – can you give it another shot?
November 7, 2016 at 1:43 pm #242436MaksymPS
AWESOME!
You are the best! Thanks a lot!
I will buy you a coffee 🙂November 7, 2016 at 4:48 pm #242504Tom
Lead DeveloperLead DeveloperThanks! 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.