How do I add a featured image to a single post page?

I’m using the Pinboard theme on WordPress 3.9.1. I’d like to edit Pinboard (or, more accurately, make a child theme) so that on single post pages, if the post has a defined featured image, it displays at the top of the post.

I’ve gathered that doing so requires editing single.php in the theme, but my knowledge of PHP is minimal at best, so when I open single.php, I can’t figure out where to make the changes–or, in fact, what changes to make.

Would anyone be willing to walk me through what it would take to include the featured image at the top of a post page such as this one? Once I understand how to properly get the image on the page, I should be able to style it the way I want.

This is probably asking for a little more hand-holding than is normal around here, so big thanks in advance.

1 Answer
1

In single.php, find <?php the_content(); ?> around line ~17.
Just before that. paste following code.

<?php if ( has_post_thumbnail() ):?>
<div class="featured-image-wrap"><?php the_post_thumbnail(); ?></div>
<?php endif; ?>

This will show featured image if assigned to the post. To change the size of image you can pass parameter to the function the_post_thumbnail(). See official documentation of the_post_thumbnail(). I believe you would use child theme for modification.

Leave a Comment