Fetch WooCommerce Categories with image

Display WooCommerce Categories with Thumbnail Without Shortcode

Last night when I was working on new WooCommerce Compatible WordPress theme, I had to build a widget which shows category image with name and description. Though I was familiar to WordPress, WooCommerce wasn’t something I explored. Since I’d never used WooCommerce before, I used little time to figure out how to make things work with WordPress.

I looked around internet and finally came up with piece of code which does the job. It was a simple as passing an extra argument to get_categories function provided by WordPress.

On line no: 3, we are asking the get_categories function to look for taxonomy called ‘product_cat’ registered by WooCommerce plugin and the rest is similar to get_categories function.

On line no: 15, We are fetching thumbnail of WooCommerce Product Category using get_woocommerce_term_meta

Leave a Reply

Your email address will not be published. Required fields are marked *