- This topic has 33 replies, 3 voices, and was last updated 2 years, 6 months ago by
Fernando.
-
AuthorPosts
-
February 5, 2023 at 7:23 pm #2522673
troyw
Hey team,
I have been talking to Woocommerce who have suggested I ask you. I am using the Woocommerce Brands Plugin to sort Brands. The Filter appears in the Left Sidebar Widget in Desktop view. This is great, however in Mobile view, all the sidebar widgets appear at the bottom of the page. This is also fine, however I would like the Brands filter to display at the top, when viewed on a mobile.
How would I do this?
Thanks
February 5, 2023 at 8:33 pm #2522708Fernando Customer Support
Hi Troyw,
How are you adding the widget? Is it through a Shortcode, a Block, or a code?
February 5, 2023 at 8:43 pm #2522713troyw
Just through the Left Sidebar Widget!
February 5, 2023 at 9:11 pm #2522730Fernando Customer Support
Can you take a screenshot of how it’s added for clarity? Uploading Screenshots: https://docs.generatepress.com/article/using-the-premium-support-forum/#uploading-screenshots
February 5, 2023 at 10:36 pm #2522788troyw
Hey Fernando,
Please try these.
By the way, I am using the Woocommerce Brands PluginFebruary 6, 2023 at 12:52 am #2522862Fernando Customer Support
I see. Thank you!
If you can add that Widget/Block on a Block Element, you can use a Block Element – Hook hooked to
after_header
.Then, add such a snippet:
add_filter( 'generate_element_display', function( $display, $element_id ) { if ( 100 === $element_id && !wp_is_mobile() ) { $display = false; } return $display; }, 10, 2 );
Replace
100
with your Element ID.Getting the Element ID: https://share.getcloudapp.com/YEuDdrnQ
Then, you can opt to hide the other Filter on mobile with this CSS:
@media (max-width: 768px) { .inside-left-sidebar aside#woocommerce_brand_nav-8 { display: none; } }
February 6, 2023 at 8:45 pm #2523970troyw
Hey Fernando,
I have implemented this as instructed, but all I get is one Brand displayed at the top of the archive page, in mobile view.When I add the Brands Widget / Block to the Element, it displays the text “No Categories”. I cannot edit this.
Here is screenshot;
https://postimg.cc/vxZPtnJ7This is what i put in the functions.php file;
add_filter( 'generate_element_display', function( $display, $element_id ) { if ( 210388 === $element_id && !wp_is_mobile() ) { $display = false; } return $display; }, 10, 2 );
Any ideas?
February 6, 2023 at 9:07 pm #2523980Fernando Customer Support
That’s the Block from the plugin right?
Can you add a static text to the Block Element just so we know it’s running?
February 7, 2023 at 2:28 pm #2525141troyw
Hey Fernando,
Yes, I used the Brands Block from the Plugin.
I also added the text ‘Brands Coming Soon’ which is appearing in Mobile view. I put the Brands Plugin below the text and you can see that it is displaying a single brand, but not the filter.Thanks
February 7, 2023 at 3:35 pm #2525196Ying
StaffCustomer SupportIf you add the block directly to a page editor, does it work?
February 12, 2023 at 4:30 pm #2530820troyw
Hi team,
So if I add the block to a page editor, it does not work, so not sure how the Element will help for this?
I have been talking to Woocommerce and they can’t really understand what I am asking.To make things easier, how can I just move the Woocommerce left side bar to the top in mobile view?
ThanksFebruary 12, 2023 at 5:49 pm #2530850troyw
Just to add to this. I am using your Theme Brands Block or at least I assume it is part of GP as it shows under themes;
https://snipboard.io/84wcyN.jpg
Bottom left of image is ‘Brands’
If I use your Category Block, it works, but the Brands one does not. Is this your block or is it Woocommerce?February 12, 2023 at 7:37 pm #2530905Fernando Customer Support
Did you deactivate the Block Element? Can you re-enable it with the Static text, and I’ll recheck what’s occurring.
February 12, 2023 at 7:48 pm #2530907troyw
Hey Fernando,
No, the element and block are active.
Please see link below and you will see that in Mobile view there is text “Brands Coming Soon” which I added to the element to show it is working. The Brands Block is also active, but not working.As I said though, I am happy to look at moving the left side bar above content when viewed on mobile and maybe then just hide the search box and keep subcategories and brands? Honestly, whatever is easier.
ThanksFebruary 12, 2023 at 9:55 pm #2530956Fernando Customer Support
I see. It seems that it really doesn’t show outside the sidebar.
As an alternative, we can do what you’re thinking of. Try adding this through Appearance > Customize > Additional CSS:
@media (max-width: 768px) { .archive div#content { display: flex; flex-direction: column; } div#left-sidebar { order: -1; } aside#woocommerce_product_categories-5, aside#dgwt_wcas_ajax_search-2 { display: none; } }
-
AuthorPosts
- You must be logged in to reply to this topic.