Tagged: move to top on mobile, product menu widget, shop
-
AuthorPosts
-
March 8, 2023 at 4:22 pm #1400487
I would like to move my product category menu widget in the sidebar of my SHOP so that that they are displayed as the first item before the products when viewing on a mobile (there is a previous thread below which is now closed).
LINK TO WEBSITE: Website
SCREENSHOT OF WIDGET: Shop widget to movePREVIOUS THREAD LINKS:
Previous Topic threadThank you so much for any help.
Regards
AnnemarieMarch 10, 2023 at 3:13 am #1400619Hey Annemarie,
Thank you for the inquiry.
Did you try the css code from the previous threads? You may need to adjust the “.shop_columns_3” selector if you are not using a 3 column layout or if there are more or less columns in your shop page.
@media only screen and (max-width: 767px) { #main > .container_wrap_first.template-shop.shop_columns_3 > .container { display: flex !important; flex-wrap: wrap !important; } #main > .container_wrap_first.template-shop.shop_columns_3 > .container > main { order: 3 !important; } #main > .container_wrap_first.template-shop.shop_columns_3 > .container > aside { order: 2 !important; } #main > .container_wrap_first.template-shop.shop_columns_3 > .container > header { order: 1 !important; } }
Best regards,
IsmaelMarch 10, 2023 at 11:00 am #1400656Hej Ismael,
I used your code and it would be perfect if I wanted to move the whole “Aside” so it is placed before “Main”. I only want to move the “product categories” widget and not the all widgets (prod. categories, Latest viewed, etc.). Could the widget be placed inside “Main” before the “template shop content” or is it more major code-wise”?
Screenshot – Debugger – Product Categories widget css
Regards,
AnnemarieMarch 11, 2023 at 6:22 pm #1400854Hi,
Try adding this code to the end of your child theme functions.php file in Appearance ▸ Editor:function custom_script() { ?> <script> window.addEventListener('DOMContentLoaded', function() { (function($){ var width = $(window).width(); if (width <= 767) { $( '#top.woocommerce-page.archive' ).each(function() { $( this ).find( '#woocommerce_product_categories-3' ).insertBefore( $(this).find('.template-shop.content') ); }); } })(jQuery); }); </script> <?php } add_action('wp_footer', 'custom_script');
Then clear your browser cache and check.
Best regards,
Mike -
AuthorPosts
- You must be logged in to reply to this topic.