<?php
// Step 1: Get the post thumbnail URL
$thumbnail_url = get_the_post_thumbnail_url();
// Step 2: Check if the thumbnail exists
if ($thumbnail_url) {
// Step 3: If thumbnail exists, display it
echo '<img src="' . esc_url($thumbnail_url) . '" alt="Post Thumbnail">';
} else {
// Step 4: If thumbnail doesn't exist, display a default image or fallback content
echo '<img src="' . esc_url(get_template_directory_uri() . '/images/default-thumbnail.jpg') . '" alt="Default Thumbnail">';
// Alternatively, you can display alternative content like a message
// echo '<p>No thumbnail available</p>';
}
?>