Archived topic
Sidebar don't show on blog post
6 replies · Started by Tonnellier on May 20, 2016
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
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.
The 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() to is_woocommerce().
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,
Seb
Your 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;
}
You know what Tom ?
You rock !! Works just perfectly... You're definitely the right man at right place !!!
Sincere Thanks from France :)
Seb
Awesome, glad I could help :)
