title: Wordpress - Get tag id by slug
body: <p>I am trying to get id\name of tag by it slug.</p>
  
  <p>Thats my code:</p>
  
  <pre><code>$tag = get_term_by('slug', 'hedoms', 'post_tag');
  $tag_id =  $tag-&gt;term_id;
  
  &lt;h1&gt;&lt;?php echo $tag-&gt;name;?&gt;&lt;/h1&gt;
  </code></pre>
  
  <p>I took it from here:
  <a href="https://codex.wordpress.org/Function_Reference/get_term_by" rel="noreferrer">https://codex.wordpress.org/Function_Reference/get_term_by</a></p>
  
  <p>I have tag with the slug <strong>hedoms</strong> but the <code>&lt;h1&gt;</code> is empty, it not returns the value. I have tried this function (get_term_by) with category - and same result.</p>
  
  <p><a href="https://i.stack.imgur.com/9gruT.png" rel="noreferrer"><img src="https://i.stack.imgur.com/9gruT.png" alt="enter image description here"></a></p>
  
  <p>the 2nd field is the slug.</p>
  
  <p>But if i do it with id and not slug, it works fine:</p>
  
  <pre><code>$tag_id = get_term_by('id', 97, 'post_tag');
  echo $tag_id-&gt;name;
  </code></pre>
  
  <p>It look like the get_term_by recognize only 'id' as field.</p>
  
  <p>What i miss here? it should be on loop or something ?</p>
  
  <p>The file i trying to do it is <code>archive-product.php</code> of Woocommerce.</p>