Support » Fixing WordPress » How to check if image title, caption, description exist befor showing it?

  • Hello.

    I use this code to display image title, caption (excerpt), description (content):

    echo get_post(get_post_thumbnail_id())->post_title;
    echo get_post(get_post_thumbnail_id())->post_excerpt;
    echo get_post(get_post_thumbnail_id())->post_content;

    But, how to check if there is any of those fields first. For example, how to check if there is caption, and if not to show some other text?

    Best regards.

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to check if image title, caption, description exist befor showing it?’ is closed to new replies.