[Resolved] Sidebar don't show on blog post

Home Forums Support [Resolved] Sidebar don't show on blog post

Home Forums Support Sidebar don't show on blog post

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #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 5 years, 2 months ago by Tom.
    #195618
    Jamal

    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.

    Agressively support the kind of work you want to see. Buy it. Talk about it. Review it.

    #195623
    Tom
    Lead Developer
    Lead Developer

    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().

    #195635
    Tonnellier

    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

    #195685
    Tom
    Lead Developer
    Lead Developer

    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;
     }
    #195691
    Tonnellier

    You know what Tom ?

    You rock !! Works just perfectly… You’re definitely the right man at right place !!!

    Sincere Thanks from France πŸ™‚

    Seb

    #195692
    Tom
    Lead Developer
    Lead Developer

    Awesome, glad I could help πŸ™‚

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