自定义帖子标签图像不显示


Custom post tag images not displaying

使用ACF,我为一组特定的自定义帖子标签添加了一个自定义图像字段。我遇到的问题是我无法显示图像。是的,我已经添加了一个图像的标签和更新。

   $term_id = 26;
    $taxonomy_name = 'tags';
    $termchildren = get_term_children( $term_id, $taxonomy_name );
    foreach ( $termchildren as $child ) {
        $term = get_term_by( 'id', $child, $taxonomy_name );
        $tag_image = get_field('tag_image');
        echo '<a href="?categories=' . $term->slug . '">'. $term->name . '</a>';
        echo $tag_image; //this bit doesn't work :(

    }

修正,新代码为:

    <?php
        $term_id = 26;
        $taxonomy_name = 'tags';
        $termchildren = get_term_children( $term_id, $taxonomy_name );
        foreach ( $termchildren as $child ) {
            $term = get_term_by( 'id', $child, $taxonomy_name );
            $tag_image = get_field('tag_image', $term);
            echo '<a href="?categories=' . $term->slug . '" class="one-third column">'. $term->name;
        ?>
            <? if( !empty($tag_image) ): ?>
                <img src="<? echo the_field('tag_image', $term); ?>" />
            <?php endif; 
            echo '</a>';

         }
    ?> 

修复的资源在这里http://www.advancedcustomfields.com/resources/get-values-from-a-taxonomy-term/

 <?php
    $term_id = 26;
    $taxonomy_name = 'tags';
    $termchildren = get_term_children( $term_id, $taxonomy_name );
    foreach ( $termchildren as $child ) {
        $term = get_term_by( 'id', $child, $taxonomy_name );
        $tag_image = get_field('tag_image', $term);
        echo '<a href="?categories=' . $term->slug . '" class="one-third column">'. $term->name;
    ?>
        <? if( !empty($tag_image) ): ?>
            <img src="<? echo the_field('tag_image', $term); ?>" />
        <?php endif; 
        echo '</a>';

     }
?> 
http://www.advancedcustomfields.com/resources/get-values-from-a-taxonomy-term/