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?
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.
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.
Click on Appearance > Customize. Then go to WooCommerce > Product Catalog. Select “show subcategories” from Category Display. Click on Save Changes.
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.
<?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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With