【发布时间】:2021-12-27 23:07:56
【问题描述】:
我需要显示最新的 8 个;
- WooCommerce 类别图片
& - WooCommerce 类别标题 在我的主页上。
我已经很容易在标题和href 链接中找到了。 但我也不知道如何获取关联的图像,以创建类别图块。
// Arguments
$args = array(
'taxonomy' => 'product_cat',
'posts_per_page' => 8,
'category_name' => $category->name,
'orderby' => 'date',
'order' => 'date'
);
$categories = get_categories( $args );
foreach( $categories as $category ) { ?>
<a href="<?php echo site_url(product-category) ?><?php echo $category->slug; ?>/">
<div class="category-tile-image">
<!-- I NEED THIS -->
<!-- I NEED THIS -->
<!-- I NEED THIS -->
<img src="#">
<!-- I NEED THIS -->
<!-- I NEED THIS -->
<!-- I NEED THIS -->
</div>
<h2><?php echo $category->name; ?></h2>
</a>
<?php } ?>
这是我想要展示的图片。
【问题讨论】:
-
@DanG 如果我的回答对您有所帮助,请考虑accepting the answer。谢谢!
标签: php wordpress woocommerce custom-wordpress-pages woocommerce-theming