Checking the thumbnail in content post

Next, what we'll do is check to see if there's a thumbnail or a featured image. For this, we'll add an if statement:

<?php if() : ?>
</article>

In the if statement, add has_post_thumbnail() and let's end the if statement as shown here:

<?php if(has_post_thumbnail()) : ?>
<?php endif; ?>
</article>

If there's a thumbnail, we'll create <div> and give it a class of post-thumbnail. In <div> we'll add <?php the_post_thumbnail(); ?> as shown here:

<?php if(has_post_thumbnail()) : ?>
<div class="post-thumbnail">
<?php the_post_thumbnail(); ?>
</div>
<?php endif; ?>

Now, under the if block add a <br /> tag, and then we will need the main content which is really easy; we can just add <?php the_content(); ?> as shown here:

<br/>

<?php the_content(); ?>
</article>

Let's save this and reload the home page, and you can see that we have the title, metadata, and content of that post as shown in the following screenshot:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.11.227