Home Forums Weaver Xtreme Theme Cant remove sidebar on single post view

This topic contains 13 replies, has 3 voices, and was last updated by  Weaver 1 week, 6 days ago.

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #50255

    Rinaldo
    Participant

    I want to remove sidebars on all woocommerce single product views, but I cant even remove it with the settings of a single post:

    https://irinaafrica.tours/travels/affordable-namibia-self-drive-safari/

    Set to No Sidebar, content only!?

    No Sidebar setting works on single pages though.

    I would like to remove them all with a snippet like this:

     add_action('woocommerce_before_main_content', 'remove_sidebar' );
        function remove_sidebar()
        {
            if( is_checkout() || is_cart() || is_product()) { 
             remove_action( 'woocommerce_sidebar', 'woocommerce_get_sidebar', 10);
           }
        }

     

    Above code works in Weaver Pro. Thank you for any hints!

    #50258

    scrambler
    Moderator

    @weaver will have to comment on the proper syntax  for an equivalent action for Xtreme

    #50261

    Rinaldo
    Participant

    Thanks!

    I thought these are two issues:

    A)The single post setting “No sidebar” doesn’t work on a product.

    B) I would like to remove the sidebar on all single posts/ products..

     

    #50262

    Weaver
    Keymaster

    I don’t know Woo well enough to know if it is creating its own sidebar for its content page.

    But the page in the link you supplied should behave just like any other page – other than the content. The header, sidebar layout, footer, all are under control of the Weaver WooCommerce page template, with the content being generated by Woo.

    There should be no reason that the action you provided should not work when added to the Weaver Xtreme Plus header filters and actions section. It is not a great idea to use “remove_sidebar” as the name, however – should be something more like “my_wvrx_remove_sidebar” or something more unique.

    One way to see if it is even being used by Woo would be to add a line of garbage code to force a runtime error:

    if( is_checkout() || is_cart() || is_product()) { 
    
       echo "remove woocommerce_get_sidebar";
    
      action_before_main_content_was_called();
    
     remove_action( 'woocommerce_sidebar', 'woocommerce_get_sidebar', 10); 
    
    }

    That will cause a runtime error, and the last thing you should see in the output is the “remove” message. If you try this and it doesn’t behave as I described, then you have some sort of error in defining the action.

     

    Note: I would recommend removing legacy Weaver II shortcode calls to eliminate the need for the shortcode compatibility plugin.

    #50266

    Rinaldo
    Participant

    Thanks for your input. I was searching some more and as I understand it now, there is custom template with Woocommerce sidebar, which these guys try to remove with this snippet.

    I dont have this special Woo sidebar. It is the default Xtreme sidebar.

    The sidebar settings work in a standard post and in all other pages used by Woo, just not on the single product page.

    Have deactivated Shortcode Comp. plugin.

     

    #50272

    scrambler
    Moderator

    if you give us a link to the Woocommerce product page I can look into a CSS solution, and may be @weaver can check if there would be a modified action that would do the job.

    #51357
    Private Reply

    Rinaldo
    Participant
    This reply has been marked as private.
    #51359

    Weaver
    Keymaster

    The page in your link is the single view page and has been set to a left sidebar. This might be via the Post Single Page option, or as a per page option. The page is also being generated via the woocommerce special page which uses the sidebar for a Page and not a single page.

    I don’t know enough about Woo commerce pages, but it is possible that there could be a conflict with single vs page for the Woo page template.

    #51363

    Rinaldo
    Participant

    I hope it is understood that the product is set to No Sidebars.

    Please look at my second link above.

    Its in principle exactly the same setting, just a different site on the Multisite network.

     

    #51364

    Weaver
    Keymaster

    There must be something very different in how either the settings are set or how the pages are generated between those two.

    I can’t tell you what exactly by the output, however. The sidebar setting is revealed in the output by the classes added to the <body> tag, and one is a left, and one is a content only.

     

     

    #51365

    Rinaldo
    Participant

    After setting in the Layout Settings Pages to No sidebar the sidebar disappeared.

    #51366

    Rinaldo
    Participant

    What I also dont understand is why the Page settings apply, while it is clearly a Post, according to Weaver Xtreme plus.

    #51375

    Weaver
    Keymaster

    As I said in my first reply:

    The page is also being generated via the woocommerce special page which uses the sidebar for a Page and not a single page.

    In other words, the sidebar of any page generated directly by Woo uses a special page theme template devoted exclusively to Woo generated pages. This is part of the Woo api, and follows Woo’s specifications. But – there were no specific guidelines telling what sort of sidebar layout to use for these Woo pages. Most themes don’t support a bunch if different sidebar layouts. So my design decision at the time was to treat these Woo pages as a regular page in terms of sidebar layout. So the option for page layout will apply to any Woo page generated by Woo to display content. It would have been possible to use the post single page sidebar layout for Woo pages, but I think it is far too late to change that design choice as there are tons of sites using Weaver and Woocommerce.

     

    #51377

    Weaver
    Keymaster

    I also just noticed one other thing.

    In the two previous links provided (hermanus-wale-wein/ vs. capetown-guided-tours/), the first one is generated by the Weaver Woo template, while the second does not use the special Woo template. I don’t know why.

Viewing 14 posts - 1 through 14 (of 14 total)

You must be logged in to reply to this topic.