WooCommerce: Move Product Gallery Thumbnails

Today we take a look at the WooCommerce Single Product Page and specifically at how to move the image gallery from under the main image to somewhere else, for example in the short description. Enjoy!

WooCommerce: Move the Product Gallery
WooCommerce: Move the Product Gallery

PHP Snippet: Move Product Gallery Thumbnails on the Single Product Page


/**
 * @snippet       Move Product Gallery Thumbs
 * @how-to        Get CustomizeWoo.com FREE
 * @sourcecode    https://businessbloomer.com/?p=19864
 * @author        Rodolfo Melogli
 * @testedwith    WooCommerce 3.4.5
 */

// #1 remove images from under featured image

remove_action( 'woocommerce_product_thumbnails', 'woocommerce_show_product_thumbnails', 20 );

// #2 add them back under short description
// note: this will need a bit of CSS customization - see below

add_action( 'woocommerce_single_product_summary', 'bbloomer_product_thumbnails_wrapper_start', 49 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_show_product_thumbnails', 50 );
add_action( 'woocommerce_single_product_summary', 'bbloomer_product_thumbnails_wrapper_end', 51 );

function bbloomer_product_thumbnails_wrapper_start() {
echo '<div class="bbloomer-thumbs">';
}

function bbloomer_product_thumbnails_wrapper_end() {
echo '</div>';
}

And a bit of CSS…


.bbloomer-thumbs div.woocommerce-product-gallery__image {
width: 30%;
margin-right: 3%;
margin-bottom: 3%;
float: left;
}

Where to add custom code?

You should place custom PHP in functions.php and custom CSS in style.css of your child theme: where to place WooCommerce customization?

This code still works, unless you report otherwise. To exclude conflicts, temporarily switch to the Storefront theme, disable all plugins except WooCommerce, and test the snippet again: WooCommerce troubleshooting 101

Related content

  • WooCommerce Visual Hook Guide: Single Product Page
    Here’s a visual hook guide for the WooCommerce Single Product Page. This is part of my “Visual Hook Guide Series“, through which you can find WooCommerce hooks quickly and easily by seeing their actual locations (and you can copy/paste). If you like this guide and it’s helpful to you, let me know in the comments! […]
  • WooCommerce: Disable Variable Product Price Range $$$-$$$
    You may want to disable the WooCommerce variable product price range which usually looks like $100-$999 when variations have different prices (min $100 and max $999 in this case). With this snippet you will be able to hide the highest price, and add a “From: ” prefix in front of the minimum price. At the […]
  • WooCommerce: Hide Price & Add to Cart for Logged Out Users
    You may want to force users to login in order to see prices and add products to cart. That means you must hide add to cart buttons and prices on the Shop and Single Product pages when a user is logged out. All you need is pasting the following code in your functions.php (please note: […]
  • WooCommerce: Add Custom Field to Product Variations
    Adding and displaying custom fields on WooCommerce products is quite simple. For example, you can add a “RRP/MSRP” field to a product, or maybe use ACF and display its value on the single product page. Easy, yes. Unfortunately, the above only applies to “simple” products without variations (or the parent product if it’s a variable […]
  • WooCommerce: Show Number Of Products Sold @ Product Page
    WooCommerce database already stores the number of products sold for you. Therefore, you may want to show such number on the product page, close to the Add To Cart button. As we’ve seen in my book Ecommerce and Beyond, showing the number of sales for each product can increase your sales conversion rate. All you […]

Rodolfo Melogli

Business Bloomer Founder

Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as an independent WooCommerce freelancer since 2011. His goal is to help entrepreneurs and developers overcome their WooCommerce nightmares. Rodolfo loves travelling, chasing tennis & soccer balls and, of course, wood fired oven pizza. Follow @rmelogli

27 thoughts on “WooCommerce: Move Product Gallery Thumbnails

  1. Hi
    Thanks for great snippet.
    I place this code into my function file. And Thumbnail change their position.
    The issue is that thumbnail loose the relation with slider. When click on the thumbnail its opening it self in browser.
    I tried this snippet in my custom theme and in Twenty Twenty theme.

    Please suggest me solution.

    Thanks

    1. Yes I guess you also need to add custom JS on top of that. Or disable zoom/gallery completely

      1. Hi Rodolfo!

        Nice tutorial as always! Could you tell us what JS to put? I have the same issue described by OP here.

        Thanks in advance!

        1. Hi Carlo, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

  2. Hi Rodolfo,

    I’m working on a self improvement/travel site that requires the user to book their choice of cabin, tent, etc. The theme I’m using (X-trail Outdoor theme) changes the format of the product (in this case accommodation) thumbnail images to display to the side of the main image, which is different from the default (images below the main image). I’d like the product to have the default format (thumbnails below the main image) instead of the way the theme formats it.

    So my question is there a way to overwrite the theme formatting of the product images to display the default formatting? I’ve reached out to the theme authors, but they said they don’t have time to help me with a solution. Any help here would be greatly appreciated.

    1. Hi Brandon, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

  3. Hello! Very helpful. I was able to move the gallery thumbnails using “woocommerce_before_single_product” instead, however it seems to have lost all functionality. As in, i cannot click the thumbnails at all which makes then unable to load into the bigger single product image space.
    Any idea what would cause that? Maybe moving them into that particular spot has something to do with it.

    1. It could be, Dave. There is also some jQuery that allows the product gallery to open in a lightbox – you’ll possibly need more than just PHP

  4. Worked for me. Thank you! Life-saver.

    1. Awesome!

  5. Hi
    Snippet already moved the product thumbnails/image gallery under short description but when I click a certain image in product thumbnail/image gallery under short description it does not change the main image but only shows a lightbox.
    So, I need to change the main image image when I click an image in the image gallery under short description?
    Thank You

    1. Hello Page, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

  6. This code removes the lightbox capabilities of my gallery. Can you comment?

    1. Hey Prokops, thanks for your comment! Does this happen if you use another theme as well?

  7. Thank you for this, but it seems that the code needs to revised again for the new version of Woo. The images gallery is big again.

    1. Red, thanks for your comment! I just tested this again with Storefront theme and it works perfectly. Maybe your theme requires custom CSS?

    2. Red, thanks for your comment! I just tested this again with Storefront theme and it works perfectly. Maybe your theme requires custom CSS?

      – Thank you for your reply. I’m using Divi theme and used a custom CSS.

    3. Its working now, but the light box and sliders doesn’t work anymore.

      1. Uhn, I guess this is Divi-specific. Sorry ๐Ÿ™‚

  8. Hello,
    your code worked perfectly for me until the upgrade which included the new gallery. The images are now large and stacked on top of each other. Plus they are the same “item” as the main picture (it doesn’t show up as a thumbnail) so you can’t change the css of the thumbnails without affecting the main picture too. I saw other people had this problem but no solutions yet… thank you for your snippets!

    1. Thanks Keri! Yes, when I update to Woo 3.0 I will revise the snippet – I put this on the list now ๐Ÿ™‚ Cheers!

    2. I have the same problem with Keri.
      Seems like a WordPress bug!

    3. I too, have the same problem. Does it have workaround now?

    4. Same problem here too, is there a fix yet?

      1. All – snippet has now been updated for Woo 3.2.3 ๐Ÿ™‚

  9. HI,

    Thanks for the awesome snippet.i wonder is there any way to move the gallery image to vertical alignment to the left side of the single product image.Any ideas?

Questions? Feedback? Customization? Leave your comment now!
_____

If you are writing code, please wrap it like so: [php]code_here[/php]. Failure to complying with this, as well as going off topic or not using the English language will result in comment disapproval. You should expect a reply in about 2 weeks - this is a popular blog but I need to get paid work done first. Please consider joining the Business Bloomer Club to get quick WooCommerce support. Thank you!

Your email address will not be published. Required fields are marked *