- This topic has 6 replies, 3 voices, and was last updated 9 years, 10 months ago by
Tom.
-
AuthorPosts
-
May 20, 2016 at 12:28 pm #195580
Tonnellier
Hi Tom,
I’m facing a little trouble on my blog single page.
Sidebar don’t show: => http://www.decolecedre.com/nettoyer-canape-cuir/
I guess the code I use on woocommerce page might be the problem
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_single() ) return 'no-sidebar'; // Or else, set the regular layout return $layout; }Would you have a suggestion to keep the product page without sidebar, and the blog article page with sidebar..if you think the problems are this sode ?
Thanks
Seb-
This topic was modified 9 years, 10 months ago by
Tom.
May 20, 2016 at 11:16 pm #195618Jamal
You are right i think the code is wrong. Try this one https://generatepress.com/forums/topic/e-commerce-help/#post-194658 .
See also if changing if(is_woocommerce() )to if(is_shop() )will do the trick.May 20, 2016 at 11:32 pm #195623Tom
Lead DeveloperLead DeveloperThe code above is targeting
is_single()which is why your sidebars aren’t showing up on single posts.If you want to target WC, change
is_single()tois_woocommerce().May 21, 2016 at 3:31 am #195635Tonnellier
Hi thanks for your return
Not doing the job, unfortunately 🙁
Just to be well understood, the actual code allows me to :
get sidebar on woocommerce categories
not display sidebar on product page.
Sidebar displays also on regular pages,And this actual code does it well,
The only missing conditions is “show also on blog post” 🙂
I hope it could help,
SebMay 21, 2016 at 9:24 am #195685Tom
Lead DeveloperLead DeveloperYour code should look 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_single() && is_woocommerce() ) return 'no-sidebar'; // Or else, set the regular layout return $layout; }May 21, 2016 at 9:40 am #195691Tonnellier
You know what Tom ?
You rock !! Works just perfectly… You’re definitely the right man at right place !!!
Sincere Thanks from France 🙂
Seb
May 21, 2016 at 9:41 am #195692Tom
Lead DeveloperLead DeveloperAwesome, glad I could help 🙂
-
This topic was modified 9 years, 10 months ago by
-
AuthorPosts
- You must be logged in to reply to this topic.