我使用以下代码来获取 Woocommerce 产品类别的缩略图 URL,但它只输出<img>带有src="unknown".
$cat_slug = t-shirts;
$thumbnail_id = get_woocommerce_term_meta( $cat_slug, 'thumbnail_id', true );
$image = wp_get_attachment_url( $thumbnail_id );
echo '<img src="'.$image.'" alt="" width="50" height="50" />';
Run Code Online (Sandbox Code Playgroud)
让它发挥作用的最佳方法是什么?
编辑
在第二次调用 jean 类别的缩略图时,它只输出<img src(unknown) alt="" width="50" height="50" />.
<div class="list-item">
<div class="item-img">
<?php
$term_slug = 't-shirts';
$taxonomy = "product_cat";
$term_id = get_term_by( 'slug', $term_slug, $taxonomy )->term_id;
$thumbnail_id = get_woocommerce_term_meta( $term_id, 'thumbnail_id', true );
$image = wp_get_attachment_url( $thumbnail_id );
echo '<img src="'.$image.'" alt="" width="50" height="50" />';
?> …Run Code Online (Sandbox Code Playgroud) 我希望在父div悬停时更改子div图像的不透明度.如何在CSS中执行此操作?
<div class="parent">
<div class="child">
<img src="" alt="" height="" width="">
</div>
</div>
Run Code Online (Sandbox Code Playgroud)