title: how do i retrieve and display the alt text of an image in wordpress?
body: <p>how do i retrieve and display the alt text of an image in wordpress? trying to substitute the title for the alt. here is the original code.</p>
  
  <pre><code>&lt;?php while ( have_posts() ) : the_post(); ?&gt;
  
    &lt;article id="post-&lt;?php the_ID(); ?&gt;" &lt;?php post_class(); ?&gt;&gt;
     &lt;header class="entry-header"&gt;
      &lt;h1 class="entry-title"&gt;&lt;?php the_title(); ?&gt;&lt;/h1&gt;
  </code></pre>
  
  <p>so in the h1 i want:</p>
  
  <pre><code>&lt;h1 class="entry-title"&gt;"alt text of image"&lt;/h1&gt;
  </code></pre>
  
  <p>tried putting it in a variable like so:</p>
  
  <pre><code> $alt_text = get_post_meta($img_id , '_wp_attachment_image_alt', true);
  &lt;h1 class="entry-title"&gt;&lt;?php echo $alt_text; ?&gt;&lt;/h1&gt;
  </code></pre>
  
  <p>but it doesn't show up. any solutions?</p>