I’ve been developing a WordPress theme as part of my new job. It’s a WooCommerce build and I’ve pretty much finished. The last thing I’m stuck on – theme wise – is how to reorder the elements of the WooCommerce shop page.
The front page is a custom shop page, which uses the display products shortcodes to display the most recent and featured products. The current layout of the products is:
Thumbnail
Product Title
Price
Add to Cart button
I’ve already managed to remove the Add to Cart button and now I’m trying to rearrange it so it shows:
Product Title
Thumbnail
Price
WooCommerce uses hooks and I cannot work out where the correct hook for the shop page/shortcodes is. It seems like a really simply thing, to rearrange the elements on a page, but I’ve been stuck on it for hours now.
Any help is greatly appreciated.
In the
content-product.php
file, change the following code from:to
This will move the image to below the title. More specifically the
do_action( 'woocommerce_before_shop_loop_item_title' );
piece of code is what is called to display the image. So moving that below the title (<?php the_title(); ?>
) should achieve what you want.The markup for products inside the archive loop is dictated by the template
content-product.php
, which you can find inplugins/woocommerce/templates/
. The good thing about WooCommerce is that you can duplicate any of the template files you find in that folder and put them in your theme folder instead; WC will then use that template instead, which you can customise to your heart’s content. All you need to do is create a new folder inside your theme folder calledwoocommerce
and inside that save a copy ofcontent-product.php
. You can then tweak that one all you like; it won’t get overridden if you update WC.To re-layout WooCommerce anything, copy the original template to your theme’s root and make any modifications to the new php file.
For example, take the original “individual item in the shop loop” template
and copy it to
Make any changes to the copy. It’ll override the original layout and not be messed up with WooCommerce updates (generally).
More Info