How to display Woocommerce Category image?

后端 未结 9 1495
说谎
说谎 2020-12-08 07:41

I use this code in PHP:

$idcat = 147;
$thumbnail_id = get_woocommerce_term_meta( $idcat, \'thumbnail_id\', true );
$image = wp_get_attachment_url( $thumbnail         


        
9条回答
  •  失恋的感觉
    2020-12-08 08:29

    Use this code this may help you.i have passed the cat id 17.pass woocommerce cat id and thats it

       prefix . "woocommerce_termmeta";
          $query="SELECT meta_value FROM {$table_name} WHERE `meta_key`='thumbnail_id' and woocommerce_term_id ={$cat_id} LIMIT 0 , 30";
          $result =  $wpdb->get_results($query);
    
          foreach($result as $result1){
              $img_id= $result1->meta_value;
          }     
    
          echo 'category image';
       ?>
    

提交回复
热议问题