how to post default thumbnail if post not created yet

I want to show a default thumbnail if a custom post not created yet.
Here is my loop:

<?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?>
<?php
if ( has_post_thumbnail( ) ) {
the_post_thumbnail( ‘full’, array( ‘class’ => ‘mySlides’ ) );
}
else {
echo ‘<img src=”dummy-image-1-1.jpg” class=”mySlides” height=”350px”/>’;
}
?>
<?php
endwhile;
wp_reset_postdata();

?>

If I created a post but not posted a thumbnail then show default thumbnail. But If I didn’t create a post yet I want to show a default thumbnail. How to fix it?

Read more here:: how to post default thumbnail if post not created yet

Leave a Reply

Your email address will not be published. Required fields are marked *