在没有缩略图的Woocommerce Wordpress Plugin中显示产品类别列表

Uma*_*oon 3 wordpress wordpress-plugin woocommerce

我使用以下短代码列出woocommerce Wordpress插件中的产品类别

<?php echo do_shortcode('[product_categories number=""]'); ?>
Run Code Online (Sandbox Code Playgroud)

问题是我需要摆脱的类别缩略图.我想隐藏它,用CSS做这件事似乎是个大麻烦.无论如何我可以在没有缩略图出现的情况下列出类别吗?

dan*_*nyo 11

您可以使用以下内容:

$args = array( 'taxonomy' => 'product_cat' );
$terms = get_terms('product_cat', $args);

if (count($terms) > 0) {
    echo '<p class="my_term-archive">';
    foreach ($terms as $term) {
        echo '<a href="/term-base/' . $term->slug . '" title="' . sprintf(__('View all post filed under %s', 'my_localization_domain'), $term->name) . '">' . $term->name . '</a>';    
    }
    echo '</p>';
}
Run Code Online (Sandbox Code Playgroud)