2

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.

6

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.

  • Thank you, Nilambar! Around line 8, there was a block that began with <header class="entry-header">. I pasted that code just inside that block, before the title, and it worked perfectly. – SpencerDub Jun 19 '14 at 16:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.