title: Wordpress: Output list with taxonomy term IDs in WP_Query loop
body: <p>I would like to output in a WP_Query loop a list with the term IDs of a certain taxonomy ('genre') of the respective post. I managed to output the first ID (as you can see in the code example). How can I get a comma separated list of all term IDs of the taxonomy 'genre' for <code>'terms'</code> in the <code>'tax_query'</code> array?</p>
  <pre><code>function my_function( $query_args) {
      $terms = get_the_terms( $post-&gt;ID, 'genre');
      $termlist = $terms[0]-&gt;term_id;
      
  
  $query_args = array(
      'post_type' =&gt; 'portfolio',
      'orderby' =&gt; 'date',
      'order' =&gt; 'ASC',
      'tax_query' =&gt; array(
          array(
              'taxonomy' =&gt; 'genre',
              'field'    =&gt; 'term_id',
              'terms'    =&gt; array($termlist),
          ),
      ),
  );
  
      return $query_args;
  
  }
  </code></pre>