title: PHP code to show featured image caption if it exists
body: <p>I want to display featured image caption in a paragraph only if it exists.</p>
  
  <p>I am trying the following without luck:</p>
  
  <pre><code>&lt;?php if (the_post_thumbnail_caption()) { echo '&lt;p class="wp-caption-text"&gt;' . the_post_thumbnail_caption() . echo '&lt;/p&gt;' } ?&gt;
  </code></pre>
  
  <p>and it's resulting in fatal error:</p>
  
  <blockquote>
    <p>C:\xampp\htdocs\builder\wp-content\themes\BuilderChild-Default\extensions\magazine-enhanced2\functions.php:88:syntax
    error, unexpected T_ECHO</p>
  </blockquote>
  
  <p>Please help.</p>