Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Woocommerce Category Thumbnails

I have a custom template for a woocommerce category page to only display the categories. I have got the system to get a list of the child categories (by using get_term_children($id, 'product_cat') and get_term_by(...)), but it only returns objects containing all the required information, except the thumbnail data. Does anyone know how I can get the thumbnail for the term?

like image 330
topherg Avatar asked Nov 28 '12 13:11

topherg


People also ask

How do I get the product category thumbnail image in WooCommerce?

Using the Dynamic Image widgetAdd the widget to the desired Listing Grid and choose the “Post Thumbnail” option as the Source. Afterward, input the thumbnail_id value into the Custom meta field/repeater key text area. The image will be pulled up right away.

How do I get the category thumbnail image in WordPress?

Getting Started You can install the plugin either through Plugins > Add New or through FTP. Once you have activated the plugin, go to Post > Categories. Now, you should be able to find the button “Set a thumbnail“. Clicking this button will display the WordPress Media Manager.

How do I display a category and subcategory in WooCommerce?

Click on Appearance > Customize. Then go to WooCommerce > Product Catalog. Select “show subcategories” from Category Display. Click on Save Changes.

What is display type in WooCommerce categories?

In WooCommerce, display type refers to the way in which products are shown on the shop page. There are three different display types available: Grid – Products are displayed in a grid, with multiple products per row. This is the default display type.


1 Answers

<?php
$thumbnail_id = get_term_meta( $cat->term_id, 'thumbnail_id', true );
$image_url    = wp_get_attachment_url( $thumbnail_id ); // This variable is returing the product category thumbnail image URL.

Notice: get_woocommerce_term_meta is deprecated

like image 81
Omid Ahmadyani Avatar answered Sep 22 '22 12:09

Omid Ahmadyani