Wordpress 在循环中显示分类acf字段

Wordpress 在循环中显示分类acf字段,wordpress,custom-post-type,advanced-custom-fields,Wordpress,Custom Post Type,Advanced Custom Fields,在高级自定义字段(ACF)中,我创建了一个图像字段,并将其添加到自定义帖子类型的类别中,这样每个类别都可以有自己的图像。然后我创建了一个循环,显示该自定义帖子类型的类别。这是可行的,但我无法获得我上传到ACF字段中的图像来显示 显示自定义帖子类型类别的代码: <?php $taxonomy = 'customposttype'; $terms = get_terms($taxonomy); if ( $terms && !is_wp_error( $terms ) ) :

在高级自定义字段(ACF)中,我创建了一个图像字段,并将其添加到自定义帖子类型的类别中,这样每个类别都可以有自己的图像。然后我创建了一个循环,显示该自定义帖子类型的类别。这是可行的,但我无法获得我上传到ACF字段中的图像来显示

显示自定义帖子类型类别的代码:

<?php $taxonomy = 'customposttype'; $terms = get_terms($taxonomy); if ( $terms && !is_wp_error( $terms ) ) : ?>
<?php foreach ( $terms as $term ) { ?>      

    <?php echo $term->name; ?>
    // display acf image

<?php } ?>  
<?php endif;?>

//显示acf图像

我尝试使用“array\u combine”,但无法使其工作。

在循环中尝试此代码

$term_image = get_term_meta( $term->term_id , 'category_afbeelding', true);

$image_attributes = wp_get_attachment_image_src( $term_image,’full’);
 if ( $image_attributes ) : 
  <img src="<?php echo $image_attributes[0]; ?>" width="<?php echo $image_attributes[1]; ?>" height="<?php echo $image_attributes[2]; ?>" />
endif;
$term\u image=get\u term\u meta($term->term\u id,'category\u afbeelding',true);
$image_attributes=wp_get_attachment_image_src($term_image,'full');
如果($image\u属性):
“宽度=”“高度=”“/>
endif;

所以你没有得到分类的图像?请给出分类法的slug。@AkshayShah的确!slug是'behandeling'。ACF字段名是:'category\u afbeelding'试试我的代码now@AkshayShah它似乎破坏了代码,我认为ACF中不存在get_image?而且它指的是“category_afbeelding”…请检查我的回答工作,在wp_get_attachment_image_src($term_image,'full')中添加了“full”;要使其在附件功能中加载完整大小的图像而不是完整的拇指传递,请检查代码