title: Use ACF Taxonomy Field as Variable in Wordpress Custom Post Type Loop
body: <p>I'm attempting to create a custom Wordpress query, using an Advanced Custom Fields field as a variable in the loop.</p>
  
  <p>The use case is a page has a custom loop on it. For example, a page about a venue displays a loop of events (the custom post type) at the bottom of the page. I want for the person creating the page to choose what event tag (a tag taxonomy on the CPT) they want to attach to the page. Then the loop runs with that field attaching to the tag query used as a variable.</p>
  
  <p>Here's my code so far:</p>
  
  <pre><code>            &lt;?php if ( get_field('event_tag') ) : ?&gt;
  
              &lt;?php 
                  $event_tag = get_field('event_tag');
                  $args = array(
                      'post_type' =&gt; 'events',
                      'posts_per_page' =&gt; 3,
                      'tag_id' =&gt; $event_tag,
                      'meta_key' =&gt; 'event_start_date',
                      'orderby' =&gt; 'meta_value',
                      'order' =&gt; 'ASC',
                      'ignore_sticky_posts' =&gt; true
                  );
              ?&gt;
              &lt;?php echo $event_tag; ?&gt;&lt;!-- This is only here to check the variable --&gt;
  
          &lt;?php else : ?&gt;
  
              &lt;?php 
                  $args = array(
                      'post_type' =&gt; 'events',
                      'posts_per_page' =&gt; 3,
                      'meta_key' =&gt; 'event_start_date',
                      'orderby' =&gt; 'meta_value',
                      'order' =&gt; 'ASC',
                      'ignore_sticky_posts' =&gt; true
                  );
              ?&gt;
  
          &lt;?php endif; ?&gt;
  
              &lt;?php $secondquery = new WP_Query( $args ); 
                  if ( $secondquery-&gt;have_posts() ) : while ( $secondquery-&gt;have_posts() ) : $secondquery-&gt;the_post(); ?&gt;
  </code></pre>
  
  <p>I'm still wanting to sort by the event date, thus the meta_key and orderby. I'm not sure if that's affecting this. A couple things to note:</p>
  
  <p>• That temporary line echoing the $event_tag does output the tag id (in this case 31). </p>
  
  <p>• I've tried wrapping that tag_id in '', echoing it, etc. But it just displays nothing.</p>
  
  <p>• Because this is querying a custom post type, I'm not sure if the standard tag even works. The tag is registered like this...if it matters.</p>
  
  <pre><code>    // Taxonomy / Tags
  function taxonomies_events_tags() {
    $args = array(
      'hierarchical'  =&gt; false, 
      'label'         =&gt; __( 'Event Tags','taxonomy general name'), 
      'singular_name' =&gt; __( 'Event Tag', 'taxonomy general name' ), 
      'rewrite'       =&gt; true, 
      'query_var'     =&gt; true,
      'show_in_rest' =&gt; true
    );
    register_taxonomy( 'custom-tag', 'events', $args );
  }
  add_action( 'init', 'taxonomies_events_tags', 0 );
  </code></pre>
  
  <p>What do I need to change in my query to get the events in the specified tag to show, still ordered by event_start_date?</p>
  
  <p>Thanks in advance.</p>