I'm trying to build the archive-custom.php page to display a tabbed list. Each custom post type is a "message" tied to a taxonomy that groups and organizes them in a "series". The taxonomy contains the information about each series, including the "series-type" it is and a graphic for each series. 

The goal is that the page displays a list of all the "series" of the type "main" with a graphic and taxonomy name. Clicking on a "series" will take you to that "series" page with a list of all "messages" 

I have gotten a query to return most of the information that I want, at this point it just returning duplicates, because my query is wrong. It returning the "series" for each "message" so if there are 4 "messages" I'm getting that "series" 4 times. I know the query needs to change.

I also was having an issue returning the name of the taxonomy. In the code below I have it returning 2 different ways - one works but returns the taxonomy name inside a link, which is unnecessary. The other just returns "array" because my syntax is wrong, and I couldn't find an example in the Wordpress codex.

I'm not very familiar with Wordpress queries, but I feel like I have a duplicate query in here that is unnecessary.

```php
<?php       
   //this initial query is returning the results for each message instead of returning just each series in the type "main"  
   $args = array(
      'post_type'   => 'messages',
      'post_status' => 'publish',
      //thanks to dmarco for pointing out this should use the meta_query instead
      //not certain how to meta_query the attached taxonomy
      'tax_query'   => array(
         array(
        'taxonomy' => 'cpt_series',
        'field'    => 'series_type',
        'terms'    => 'main'
         )
      )
   );

   $series = new WP_Query( $args );
   if( $series->have_posts() ) :
?>
      <ul>
<?php
      while( $series->have_posts() ) :
         $series->the_post();

         //get the custom taxonomy fields and assign them to var
         //this query is to access the custom post type fields.
         $types = get_terms( array(
            'taxonomy' => 'cpt_series',
            'hide_empty' => true,
         ));

         foreach($types as $type) {
            $image = get_field('series_graphic', 'cpt_series_' . $type->term_id . '' );
            $seriesLink = get_term_link($type->term_id, $taxonomy = 'cpt_series');
            //This title doesn't work - syntax is wrong
            $seriesTitle = wp_get_post_terms('name');

            if ( has_term( $type->term_id, 'cpt_series')) {
               $seriesGraphic = $image['url'];
            }
         }
?>

         <li>
            <a href="<?=$seriesLink?>">
<?php 
               echo '<img src="' . $seriesGraphic . '" />';
               echo $seriesTitle;
               $seriesTitle = the_terms($post->ID, 'sermon_series', '');
?>
            </a>
         </li>
<?php
      endwhile;
      wp_reset_postdata();
?>
      </ul>
<?php
   else :
      esc_html_e( 'No series available!', 'text-domain' );
   endif;           
?>

```

It's very close to doing what I want, again just getting the "series"
 for each "message" instead of just a list of all the "series" in the type "main". Would love to know how to properly get the 'name' returned as well. Thanks.