Giø
Giø

Reputation: 61

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

Upvotes: 0

Views: 8205

Answers (3)

jirodearmas
jirodearmas

Reputation: 1

Added this CSS for the product title and it worked fine for me. I used media query of course.

position: absolute;
top: 0px;

Upvotes: 0

Harkály Gergő
Harkály Gergő

Reputation: 841

If you put code into a plugin, you must wait for WooCommerce loading:

add_action('plugins_loaded', function()
{
    // move product's title before product thumbnail instead of next to that
    remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_title', 5);
    add_action('woocommerce_before_single_product_summary', 'woocommerce_template_single_title');
}

Upvotes: 0

MSTannu
MSTannu

Reputation: 1033

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() ).

Upvotes: 2

Related Questions