Advertisement
Guest User

Untitled

a guest
May 20th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.44 KB | None | 0 0
  1. add_action( 'woocommerce_archive_description', 'tim_cat_image', 2 );
  2. function tim_cat_image() {
  3.     if ( is_product_category() ){
  4.         global $wp_query;
  5.         $cate = $wp_query->get_queried_object();
  6.         $thumbnail_id = get_woocommerce_term_meta( $cate->term_id, 'thumbnail_id', true );
  7.         $image = wp_get_attachment_url( $thumbnail_id );
  8.         if ( $image ) {
  9.             echo '<img src="' . $image . '" alt="' . $cate->name . '" />';
  10.  
  11.         }
  12.     }
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement