[Resolved] Remove sidebar from custom archive page

Home Forums Support [Resolved] Remove sidebar from custom archive page

Home Forums Support Remove sidebar from custom archive page

Viewing 15 posts - 1 through 15 (of 18 total)
  • Author
    Posts
  • #1338096
    Silvano

    I built a website for commerce and auctions. Each of these have their own archive page (product archive and product archive auction). I need to remove the sidebar from the product archive auction page.
    I got with this filter:

    add_filter( 'generate_sidebar_layout', function( $layout ) {
    	global $product;
        
        if ( method_exists( $product, 'get_type' ) && $product->get_type() == 'auction' ) {
            return 'no-sidebar';
        }
        
        return $layout;
     } );

    But the sidebar space continues. Could you help me with that? I wanted the product area to take the entire width.

    #1338156
    Leo
    Staff
    Customer Support

    Hi there,

    Any chance you can link us to the site in question?

    You can edit the original topic and use the private URL field.

    Let me know 🙂

    #1338635
    Silvano

    Hi Leo,
    I have this demo:
    https://silper.net.br/artauction/leiloes/
    where:
    loja link = store
    leilões link = auction

    the archive page for auctions is a copy of woocommerce product-archive page renamed to product-archive-auction used by the plugin Wocommerce Simple Auction to archive auction separated from regular products

    I tried remove sidebar in this archive with various conditions tag, but I got sucess only with that function.

    #1339049
    Leo
    Staff
    Customer Support

    Is the sidebar layout in the WooCommerce panel already set to no sidebar?
    https://docs.generatepress.com/article/woocommerce-overview/#shop

    #1339435
    Silvano

    Yes I did, but in this case sidebar is removed from shop page too and I don’t want this. I want remove from auctions archive only. :/

    #1339522
    Tom
    Lead Developer
    Lead Developer

    That’s strange, can you try this?:

    add_filter( 'generate_sidebar_layout', function( $layout ) {
        global $product;
        
        if ( method_exists( $product, 'get_type' ) && $product->get_type() == 'auction' ) {
            return 'no-sidebar';
        }
        
        return $layout;
     }, 100 );

    Any change?

    #1339541
    Silvano

    Hi Tom,
    Unfortunately, nothing has changed.

    With this condition used by filter I was able to remove the sidebar only on the auction archive page, but the row does not expand to full width.

    #1340510
    Tom
    Lead Developer
    Lead Developer

    Do you have a sidebar option set in Customize > Layout > WooCommerce? Or is it set to inherit?

    #1340759
    Silvano

    Is set to left sidebar (sidebar-content)

    As you can see in my demo:
    https://silper.net.br/artauction

    the store page(loja) continues with the sidebar and the auction (leilões) is without the sidebar but the sidebar area is still reserved.

    #1341737
    Tom
    Lead Developer
    Lead Developer

    It could be that $product->get_type() is available too late during the page load. For example, your <body> element still has the left-sidebar class, so at that point, the above filter isn’t being read. It’s not until the content area that the sidebar is removed.

    I wonder if there’s another condition you can try?

    #1341928
    Silvano

    Hi,

    I got the desired result by changing the permanent links to default, and then I used the “is_page” to select from page ID, it worked. But in this case the page url shows the ID instead of the name… My client will not like this. : /

    Other than that I tried several combinations but the only one that returned a result close to the desired one was this one. The others I did removed the sidebar and adjusted the row to full width but both on the store page and on the auction page.

    The current archive page is just a copy of product-archive.php renamed to product-archive-auction.php, perhaps a good way out of this is to build a custom archive page for this product type.

    #1341957
    Tom
    Lead Developer
    Lead Developer

    You can actually is is_page( 123 ) along with having pretty permalinks – no need to set them to default in order for it to work.

    #1341979
    Silvano

    I know that, but the conditional only worked when i changed the parmalinks to pattern

    #1341990
    Tom
    Lead Developer
    Lead Developer

    Hmm, I wonder if you could use is_product_category()?: https://docs.woocommerce.com/document/conditional-tags/#section-5

    #1342063
    Silvano

    Hi Tom,
    It doesn’t work either.
    From what I’ve seen, auction is a term in the product_type taxonomy
    I tried it with terms_exists (auction, product_type), this removes both shop archive and auction archive either.

    I contacted Woocommerce Simple Auction plugin support … I’ll wait until tomorrow.

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