Get images from custom taxonomy terms
<p>Ok, I don't know if asking a new question is allowed for this. But I think its a bit different than my previous question. (if not, please tell me).</p>

<p>Im trying to get featured images from my custom taxonomy terms. Yesterday I got pretty far, but my client wants to add the names of the team members. So I'm kind of back to the drawing board on this one. </p>

<p>My theme is made up out of four different collapsible panels. With a Custom Post type and a loop. </p>

<p>So I made a custom taxonomy <code>ons_team</code> because I do not want to show the team members on every panel. So I checked the boxes on the ctp where I want the team members to be shown.</p>

<p>But now that the client wants to add the names of the team members I'm forced to use a different code. Yesterday I got it to work with this code.</p>

<pre><code>&lt;?php $terms = get_the_terms( $post-&gt;ID , 'ons_team' ); 
                    print apply_filters( 'taxonomy-images-list-the-terms', '', array(
                                'before'       =&gt; '&lt;div class="ons-team"&gt;',
                                'after'        =&gt; '&lt;/div&gt;',
                                'before_image' =&gt; '&lt;span&gt;',
                                'after_image'  =&gt; '&lt;/span&gt;',
                                'image_size'   =&gt; 'detail',
                                'taxonomy'     =&gt; 'ons_team',
                            ) );
                    foreach ( $terms as $term ) {
                        $term_link = get_term_link( $term, 'ons_team' );
                        if( is_wp_error( $term_link ) )
                        continue;


                    } 
                ?&gt;
</code></pre>

<p>This only shows the team members on the panel in which I checked the boxes. But I cannot add the names of the team members to this code.</p>

<p>So I got it to work on the single page using this code:</p>

<pre><code>&lt;?php   
// List of image links

$terms = apply_filters( 'taxonomy-images-get-terms', '', array( 'taxonomy' =&gt; 'ons_team' ) );

foreach( (array) $terms as $term) {
echo '&lt;div class="col s6 m6 l3 teamimage"&gt;&lt;a href="' . esc_attr( get_term_link( $term ) ) . '" title="' . sprintf( __( "%s" ), $term-&gt;name ) . '" ' . '&gt;' . wp_get_attachment_image( $term-&gt;image_id, 'destacado-proyectos-home' ) . '&lt;/a&gt;';

echo '&lt;h2 class="truncate"&gt;' . sprintf( __( "%s" ), $term-&gt;name ) . '&lt;/h2&gt;';
     echo '&lt;/div&gt;';
     }
   ?&gt;
</code></pre>

<p>But if I use that code on the panel I WANT the information to show up. It shows it across all the panels, and not on the only one I want to show it on.</p>

<p>I tried using a combination of both but then every panel still shows the images and names.</p>

<pre><code> &lt;?php $terms = get_the_terms( $post-&gt;ID , 'ons_team' ); 
                    $terms = apply_filters( 'taxonomy-images-get-terms', '', array( 'taxonomy' =&gt; 'ons_team' ) );

                          foreach( (array) $terms as $term) {
                            echo '&lt;div class="col s6 m6 l3 teamimage"&gt;&lt;a href="' . esc_attr( get_term_link( $term ) ) . '" title="' . sprintf( __( "%s" ), $term-&gt;name ) . '" ' . '&gt;' . wp_get_attachment_image( $term-&gt;image_id, 'destacado-proyectos-home' ) . '&lt;/a&gt;';
                            echo '&lt;h2 class="truncate"&gt;' . sprintf( __( "%s" ), $term-&gt;name ) . '&lt;/h2&gt;';
                            echo '&lt;/div&gt;';
                          }
                    foreach ( $terms as $term ) {
                        $term_link = get_term_link( $term, 'ons_team' );
                        if( is_wp_error( $term_link ) )
                        continue;


                    } 
                ?&gt;
</code></pre>

<p>Placing the code between the foreach or any other place kind of breaks the code. Is it possible that this doesn't work because I'm using $term / $terms alot?</p>

<p>Using it like this:</p>

<pre><code>&lt;?php $terms = get_the_terms( $post-&gt;ID , 'ons_team' ); 

                    foreach ( $terms as $term ) {
                        $term_link = get_term_link( $term, 'ons_team' );
                        $terms = apply_filters( 'taxonomy-images-get-terms', '', array( 'taxonomy' =&gt; 'ons_team' ) );

                          foreach( (array) $terms as $term) {
                            echo '&lt;div class="col s6 m6 l3 teamimage"&gt;&lt;a href="' . esc_attr( get_term_link( $term ) ) . '" title="' . sprintf( __( "%s" ), $term-&gt;name ) . '" ' . '&gt;' . wp_get_attachment_image( $term-&gt;image_id, 'destacado-proyectos-home' ) . '&lt;/a&gt;';
                            echo '&lt;h2 class="truncate"&gt;' . sprintf( __( "%s" ), $term-&gt;name ) . '&lt;/h2&gt;';
                            echo '&lt;/div&gt;';
                          }
                        if( is_wp_error( $term_link ) )
                        continue;


                    } 
                ?&gt;
</code></pre>

<p>Kind of works, but then it show the team member like 10 times in a row... </p>

<p>Any help is much appreciated!</p>