Dealing with post without an image

So now what we want to do is take care of the posts that don't have an image. Right now the Hello World post doesn't have one and it's not showing up because we haven't put any code in that yet. So let's check for the thumbnails now:

  1. This div is where the code for the post without an image will go:
      <div class="col-md-12">
<h2>
<a href="<?php echo the_permalink(); ?>">
<?php echo the_title(); ?>
</a>
</h2>

<p class="meta">
Posted at
<?php the_time(); ?> on
<?php the_date(); ?> by
<strong><?php the_author(); ?></strong>
</p>

<div class="excerpt">
<?php echo get_the_excerpt(); ?>
</div>
<br>
<a class="btn btn-default" href="<?php
the_permalink(); ?>">
Read More &raquo;
</a>
  1. Now we can have posts without images and not have just an empty space:

If we didn't use the conditional statement, then this would just have an empty space where the image was supposed to go.

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

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