Created
November 19, 2020 06:41
-
-
Save yousufansa/35e1c70ba974bd1af45210021be66a77 to your computer and use it in GitHub Desktop.
Cartzilla - Display Product Category Description & Image on Product Category page before products loop
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if( ! function_exists( 'cz_child_display_product_category_description_with_image' ) ) { | |
| function cz_child_display_product_category_description_with_image() { | |
| 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_image_src( $thumbnail_id ); | |
| $term_description = term_description(); | |
| if( ! empty( $image ) || ! empty( $term_description ) ) { | |
| ?><div class="media align-items-center mb-4"><?php | |
| if( ! empty( $image ) ) { | |
| ?><img class="mr-3" src="<?php echo $image[0]; ?>" width="<?php echo $image[1]; ?>" height="<?php echo $image[2]; ?>" /><?php | |
| } | |
| if( ! empty( $term_description ) ) { | |
| ?><div class="media-body"><?php echo $term_description; ?></div><?php | |
| } | |
| ?></div><?php | |
| } | |
| } | |
| } | |
| } | |
| add_action( 'woocommerce_before_shop_loop', 'cz_child_display_product_category_description_with_image', 16 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment