Search code examples
wordpresswoocommercetitleproduct

Woocommerce - Move titles over thumbnails of products in Category page


I need to move the titles of the products, while I am browsing the category page, over their thumbnails

Details:

I have created a shop page where I only display the categories. Every category contains 1 to 10 products.

Once I click a category, I land on a page where I see all of the products in that category.

I would like to see the titles of those products appearing over their thumbnails.

Thank you


Solution

  • A few more details relating to your parituclar setup are needed to give a proper answer. However, I'm going to assume you have everything at default. This is what you would need to add to the end of functions.php in your active theme folder:

    remove_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10 );
    add_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10 );
    

    For reference, check https://github.com/woothemes/woocommerce/blob/master/templates/content-product.php and https://github.com/woothemes/woocommerce/blob/master/includes/wc-template-hooks.php

    If this does not work, check:

    • that you use the latest version of woocommerce. Actually a few versions back should work the same, but not too far back.
    • that your woocommerce templates are not overwritten. Check your theme folder for a file called content-product.php or in a subfolder woocommerce/content-product.php. If that has been altered, you need to adjust accordingly, perhaps by making changes right there.
    • that your theme does not already mess around with product display hooks. If it does, find out what's different.

    Please note that this changes behavior for all woocommerce loops, such as any shortcodes you might be using and the "related products" section in single product view, if that is enabled. To affect only categories, the changes should be wrapped in a condition check ( is_product_category() ).