title: wordpress custom post type loop by tag id
body: <p>I'm trying to make a loop of a custom type of posts by tag ID.<br>
  This is the original code:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?php $args = array(
              'post_type' =&gt; 'kana_portfolio',
              'meta_key'   =&gt; 'choose_layout_2',
              'meta_value' =&gt; 'layout-1',
              'posts_per_page' =&gt; -1
          );
          $posts = get_posts($args);
          $term_array = array();
          $portfolio_term_array = array();
          foreach ( $posts as $post ) : setup_postdata( $post );
              $terms = wp_get_post_terms( get_the_ID(), 'kana_genre');
              foreach($terms as $term){
                  $term_array[$term-&gt;slug] = $term-&gt;name;
                  $portfolio_term_array[] = $term-&gt;slug;
              }
          endforeach;
          wp_reset_postdata(); ?&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>Since I need to loop only the posts in a certain category (of custom posts type) having id 31 I added "'tag_id' => 31" after "'posts_per_page' => -1"</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?php $args = array(
              'post_type' =&gt; 'kana_portfolio',
              'meta_key'   =&gt; 'choose_layout_2',
              'meta_value' =&gt; 'layout-1',
              'posts_per_page' =&gt; -1,
              'tag_id' =&gt; 31
          );
          $posts = get_posts($args);
          $term_array = array();
          $portfolio_term_array = array();
          foreach ( $posts as $post ) : setup_postdata( $post );
              $terms = wp_get_post_terms( get_the_ID(), 'kana_genre');
              foreach($terms as $term){
                  $term_array[$term-&gt;slug] = $term-&gt;name;
                  $portfolio_term_array[] = $term-&gt;slug;
              }
          endforeach;
          wp_reset_postdata(); ?&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p><strong>[EDIT]</strong><br>
  I have another loop below in the page and I tried to insert 'cat'=>31 tax_query array</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>                &lt;?php $number_posts_to_display = get_field('number_of_posts_to_display');
                  $display_order = get_field('post_display_order');
                  $portfolio = array(
                      'post_type' =&gt; 'kana_portfolio',
                      'posts_per_page' =&gt; $number_posts_to_display,
                      'order' =&gt; $display_order,
                      'meta_key'   =&gt; 'choose_layout_2',
                      'meta_value' =&gt; 'layout-1',
                      'tax_query' =&gt; array(
                          array(
                              'taxonomy' =&gt; 'kana_genre',
                              'field'    =&gt; 'slug',
                              'terms'    =&gt; $portfolio_term_array,
                          ),
                      ),
                  );
                  $portfolio_loop = new WP_Query($portfolio); ?&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>But nothing is showed, how can I do?</p>