How to display Woocommerce Category image?

后端 未结 9 1491
说谎
说谎 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:31

    You may also used foreach loop for display category image and etc from parent category given by parent id.

    for example, i am giving 74 id of parent category, then i will display the image from child category and its slug also.

    ** 0, 'orderby' => 'ASC', 'child_of'=>'74'));
    foreach($catTerms as $catTerm) : ?>
    term_id, 'thumbnail_id', true ); 
    
    // get the image URL
    $image = wp_get_attachment_url( $thumbnail_id );  ?>
    
  • name; ?>
  • **

提交回复
热议问题