Site icon Hip-Hop Website Design and Development

Present div <figcaption> if it exists different sensible no <figcaption> needs to be displayed in HTML

I’m studying PHP and I’m attempting so as to add on featured photographs. Nonetheless, if the has not be specified on a picture, I do not need to show within the HTML. At present the code at all times outputs in HTML whether or not it has been set or not.

Any assist can be a lot appreciated. Thanks.

     perform get_caption_and_desc_post_image() {
    world $publish;
      $thumbnail_id    = get_post_thumbnail_id($post->ID);
    $thumbnail_image = get_posts(array('p' => $thumbnail_id, 'post_type' => 'attachment'));
     if ($thumbnail_image && isset($thumbnail_image[0])) {
    echo '<figcaption>'.$thumbnail_image[0]->post_excerpt.'</figcaption> <div class="image- 
    description">'.$thumbnail_image[0]->post_content.'</div>';
    }
    else {
return; 
        }
       }
      add_filter( 'entry_content_before', 'get_caption_and_desc_post_image' , 9);