我无法显示类别的缩略图

时间:2019-03-20 15:55:09

标签: wordpress thumbnails

你好吗

我是wordpress的新手,需要一些帮助,因为 我无法显示类别的缩略图。

我该怎么办?

echo '<ul>';

$args=array(
'orderby' => 'name',
'order' => 'ASC',
'taxonomy' => 'portfolio-types',
);

$categories=get_categories($args);

foreach($categories as $category) {
    echo '<li><a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "Ver postagens em %s" ), $category->name ) . '" ' . '>' . $category->name.'</a> ';
    echo '<br />'. $category->description . ' ';
    echo $category->description;
    echo '('. $category->count . ')</li>';  

    $thumbnail_id = get_post_meta($categories->ID, '_thumbnail_id', true);

   if ($thumbnail_id) {
            $thumb = wp_get_attachment_image($thumbnail_id, array($width, $height), true);
             echo $thumb;
        } else {
            echo 'no thumbnail';
            }


}


echo '</ul>';

0 个答案:

没有答案