title: Using Custom Taxonomy Term ID for Custom Field
body: <p>I have created a custom single-sermons.php template file for my sermons custom post type and want to include the sermon speaker image custom field of the sermon speaker for this post.</p>
  
  <p>Custom Taxonomy ID: sermon_speaker
  Custom Field ID: sermon_speaker_image</p>
  
  <p>I have been able to get the taxonomy term ID to display as a number on the page using:</p>
  
  <pre><code>&lt;?php
  
  $terms = wp_get_post_terms($post-&gt;ID, "sermon_speaker");
  foreach ($terms as $termid) {  
  echo $termid-&gt;term_id;
  } 
  
  ?&gt;
  </code></pre>
  
  <p>I'm trying to figure out how to use this term ID in the code below where I currently have . $term_id so that it adds the term ID to the end of the background image URL.</p>
  
  <pre><code>&lt;div class="sermon-speaker-image" style="background-image: url('&lt;?php the_field( 'sermon_speaker_image', 'sermon_speaker_' . $term_id ); ?&gt;');"&gt;&lt;/div&gt;
  </code></pre>
  
  <p><strong>Update:</strong> The following code is a working solution based on the answer below:</p>
  
  <pre><code>&lt;?php
  global $post;
  
  // load all 'sermon_speaker' terms for the post
  $terms = get_the_terms($post-&gt;ID, 'sermon_speaker');
  
  // we will use the first term to load ACF data from
  if( !empty($terms) )
  {
      $term = array_pop($terms);
  
      $custom_field = get_field('sermon_speaker_image', $term );
  
  }
  ?&gt;
  &lt;div class="sermon-speaker-image" style="background-image: url('&lt;?php echo $custom_field; ?&gt;');"&gt;&lt;/div&gt;
  </code></pre>