Category image inside menu items
-
Hello,
I have created a child theme of an existing theme that supports WooCommerce and I’m customized it. I created a full screen element and I’m displaying a specific menu. That menu contains product categories and subcategories.
I want to retrieve the parent’s category image(I have the category id )
I checked the code below but this is working only on woocommerce pages(archives, signle and etc).
if ( is_product_category() ){ global $wp_query; $cat = $wp_query->get_queried_object(); $thumbnail_id = get_term_meta( $cat->term_id, 'thumbnail_id', true ); $image = wp_get_attachment_url( $thumbnail_id ); if ( $image ) { echo '<img src="' . $image . '" alt="' . $cat->name . '" />'; } }
So my question is, how to retrieve the category image inside the header.php ??
Outside of WooCommerce loop and pages…
:/Thanks in advance.
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Category image inside menu items’ is closed to new replies.