One of the latest WooCommerce versions introduced an optimized product gallery on the single product page. If your products have multiple images and therefore use the product gallery, you might want to also add content below the gallery itself. But…
If you’re familiar with WooCommerce customization and WooCommerce hooks (and specifically the ones of the Single Product Page), you’ll know it’s now impossible to add content under the image as it used to be done with the “woocommerce_product_thumbnails” hook.
In fact, the new gallery completely replaces the default content via JQuery, including that hook. Adding content is not as easy as it used to be. So, here’s the workaround (you might want to check how it behaves on mobile or maybe completely hide this for small devices – this has been tested on desktop only).
PHP Snippet: Add Content Below the Gallery Images @ WooCommerce Single Product
/**
* @snippet Add Content Below the Gallery Images @ WooCommerce Single Product
* @how-to businessbloomer.com/woocommerce-customization
* @author Rodolfo Melogli, Business Bloomer
* @compatible WooCommerce 4.1
* @community https://businessbloomer.com/club/
*/
// Note 1: this works on Storefront theme, might need customization for other themes
// Note 2: class "woocommerce-product-gallery" is vital for inheriting CSS float left, margins and widths
add_action( 'woocommerce_after_single_product_summary' , 'bbloomer_add_below_prod_gallery', 5 );
function bbloomer_add_below_prod_gallery() {
echo '<div class="woocommerce-product-gallery" style="background: #fdfd5a; padding: 1em 2em">';
echo '<span>THIS IS A TEST. YOU CAN ADD TEXT, IMAGES AND ANY HTML</span>';
echo '</div>';
}
Worked for me! Thank you a lot, I wasted a couple of hours struggling with this task, but your article saved me! Thank you
Nice!
Hi,
I used this code but it renders the content in between the left and right columns’ content. I mean, it shows the text in the middle of the image and product data in the right column area.
Thanks
Sohaib
Maybe you need additional CSS depending on your theme
Found your example and want to know how I can show different content for each product?
Rubb, 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!
Apparently this doesn’t work with newer version of WooCommerce that is using flex for gallery images. Any tips?
Hello Zia, if you remove the “woocommerce-product-gallery” class, does it work?
nope, doesn’t work.
seen at the bottom.
You may need additional CSS then, sorry
Thanks for this. Is there a way to add pages to a single product. For instance when customers click a good, it takes them to a product page. On that product page, I want them to be able to enter the size and then click a button that we open another page for the, to select the fabric they want to use, and then a next page to summarise what they have selected next to the original style
Hello Lady, thanks for your comment! I think you can do that (or similar) with this: https://businessbloomer.com/woocommerce-how-to-sell-product-customizations-add-ons/
Any way to wrap a function into this function? I’m trying to move woocommerce_template_single_rating (among other things) under the product thumbnail area. Thanks.
Hey there, thanks for your comment – yes, of course, you can enter there any WooCommerce function you like. Give it a go
Hi, Thanks for Snippet
My question is; Is it possible to modify it to be visible in specific Categories?
Thanks
Hey Boun, thanks so much for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. Thanks a lot for your understanding! ~R
While this works to show static data I am having difficulty making it work to move one of the woo template functions underneath the picture. Eg. I would like to move the variation select form under the picture and gallery so that users can quickly flip between the options and see corresponding picture without scrolling back up to the top of the page. Any tips there? Thanks!
Hey Adan, thanks for your comment 🙂 You also need to make sure you’re moving the “form” otherwise those select and input fields won’t work. It’s a very delicate thing. Hope this helps
Worked for me! Thanks a mill!
🙂
Dear Sir,
I want to add some pictures (at thumbnail product) to all single products page. Please help me.
Hello Trung – thanks so much for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. Thanks a lot for your understanding! ~R
Yes it works but having a positioning issue, as displayed in the example image.
Hey Samuel, thanks for your comment! You might need custom CSS specific to your theme, this snippet can’t be valid for all themes 🙂
I have tried to add this code in my Avada child theme function.php but nothing happens 🙁
Hey Steph, thanks for your comment! Probably Avada has deep WooCommerce customization so default snippets don’t always work. Try to switch temporarily to another theme just to make sure the snippet works 🙂
Hi I’ve tried this and it work’s, work in the sense of it has an output… but it is different from the example image above because it is positioned below the product gallery and description.
Hey Ray, thanks for your comment! Try with a “clear: left”, see comment https://businessbloomer.com/woocommerce-add-content-below-the-single-product-page-images/#comment-37054 – let me know 🙂
Good day. Thank you so much for this. I got it to work perfectly here: https://www.johnnieandpaw.co.za/product/pierced-pendant-resin/
But … my question is, is it possible to hide it on a mobile phone? If you could help me with that I will be eternally grateful.
Using Divi.
Hello there and thanks for your question! Of course, you could try wrapping the inside of the function between a conditional check, and use the helpful WordPress function wp_is_mobile():
When I tried this in Storefront theme it put the yellow div above the Description/Additional Information/Reviews tabs.
This change seems like a bad regression. Maybe the solution is to add a ‘replacement’ action e.g.
do_action(‘woocommerce_after_product_thumbnails’)
near the bottom of templates/single-product/product-image.php.
If you can think of a good use case for putting info under the thumbnails then I’ll happily submit a pull request.
Cheers Damien!
1) Do your products have a product gallery? This won’t work if there is only 1 featured image
2) Did you keep the CSS class inside the PHP snippet? That gives you the float:left and aligns the div under the product gallery
Let me know 🙂
1) Yes, product image and 2 images in product gallery.
2) Yes, CSS retained.
Screenshot: https://i68.tinypic.com/vfvbjl.png
Ah thanks Damien! Possibly the element is floating left but because there is more vertical spacing in the right columns is going there. Try either adding a short description that “pushes” the element to the left (as a test) to see if this theory is correct.
After this simple test, maybe you can solve this by adding “clear: left” to the yellow DIV?
thanks for your sharing ! this is helpful articles !
Cool 🙂