- This topic has 17 replies, 3 voices, and was last updated 3 years, 9 months ago by Tom.
-
AuthorPosts
-
June 22, 2020 at 6:04 pm #1338096Silvano
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.
June 22, 2020 at 7:22 pm #1338156LeoStaffCustomer SupportHi 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 🙂
June 23, 2020 at 6:13 am #1338635SilvanoHi Leo,
I have this demo:
https://silper.net.br/artauction/leiloes/
where:
loja link = store
leilões link = auctionthe 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.
June 23, 2020 at 9:24 am #1339049LeoStaffCustomer SupportIs the sidebar layout in the WooCommerce panel already set to no sidebar?
https://docs.generatepress.com/article/woocommerce-overview/#shopJune 23, 2020 at 2:45 pm #1339435SilvanoYes 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. :/
June 23, 2020 at 4:36 pm #1339522TomLead DeveloperLead DeveloperThat’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?
June 23, 2020 at 5:15 pm #1339541SilvanoHi 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.
June 24, 2020 at 10:01 am #1340510TomLead DeveloperLead DeveloperDo you have a sidebar option set in Customize > Layout > WooCommerce? Or is it set to inherit?
June 24, 2020 at 3:05 pm #1340759SilvanoIs set to left sidebar (sidebar-content)
As you can see in my demo:
https://silper.net.br/artauctionthe store page(loja) continues with the sidebar and the auction (leilões) is without the sidebar but the sidebar area is still reserved.
June 25, 2020 at 9:44 am #1341737TomLead DeveloperLead DeveloperIt could be that
$product->get_type()
is available too late during the page load. For example, your<body>
element still has theleft-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?
June 25, 2020 at 1:44 pm #1341928SilvanoHi,
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.
June 25, 2020 at 2:09 pm #1341957TomLead DeveloperLead DeveloperYou can actually is
is_page( 123 )
along with having pretty permalinks – no need to set them to default in order for it to work.June 25, 2020 at 2:26 pm #1341979SilvanoI know that, but the conditional only worked when i changed the parmalinks to pattern
June 25, 2020 at 2:44 pm #1341990TomLead DeveloperLead DeveloperHmm, I wonder if you could use
is_product_category()
?: https://docs.woocommerce.com/document/conditional-tags/#section-5June 25, 2020 at 5:16 pm #1342063SilvanoHi 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.
-
AuthorPosts
- You must be logged in to reply to this topic.