$cats = array(\'taxonomy\'=>\'types\');
$categories = get_categories($cats);
foreach($categories as $category) {
echo \'<p>Category:\'. $category->name.\' </p> <br>\';
echo \'<p> Description:\'. $category->description . \'</p> <br>\';
$term_id = $category->term_id;
echo $term_id;
$meta_image = wp_get_attachment_image($category->$term_id);
echo $meta_image;
?>
<img src="<?=$meta_image?>" alt="image">
<?php
}
不显示自定义帖子类别的图片
1 个回复
最合适的回答,由SO网友:sagar 整理而成
首先$category->$term_id
是否使用错误$category->term_id
我不认为$category->$term_id
将为您提供所需的结果
为此,您必须在后端为映像创建一些元数据。
term_image_id = get_term_meta( $category->term_id, \'your-term-id\', true );
这里的术语id是$category->term_id
术语值为your-term-id
你能检查一下这是否有效吗?