Example 1 — Check the current post
Print a message that tells you if the post has a featured image.
<?php
if ( has_post_thumbnail() ) {
echo 'This post has a featured image.';
} else {
echo 'This post has no featured image.';
} How It Works
has_post_thumbnail()checks the current post.- It returns
true, so the first message prints. - With no featured image, the
elsemessage prints instead.

