Featured Image auto insert into posts

  • Learning21st


    I am looking for a way to get my featured images to automatically insert into their posts. I have added to the functions.php the following code:

    add_theme_support( 'post-thumbnails' );

    And need to add:

    <?php the_post_thumbnail(); ?>

    into the correct spot in the single.php file.

    I am following tips from here: http://www.doitwithwp.com/show-featured-image-wordpress-posts/

    but can’t get the image to appear in the correct spot. What am I missing?



    Add this to your child-theme’s functions.php file, anywhere between opening and closing php tags,

    function featured_img_thumb() {
    <span class="post-thumbnail">
    <?php the_post_thumbnail(); ?>

    Untested, but should work. This will display the featured image before the post content.



    Awesome, Thanks….I was able to edit the loop-single.php with a

    <?php echo get_the_post_thumbnail(null,'large');?>

    but I wonder if the way mentioned above would be more stable.



    Yes, if you add the above code to child theme’s functions.php file, you don’t have to edit loop-single.php whenever you update the theme.

Viewing 4 posts - 1 through 4 (of 4 total)

  • You must be logged in to reply to this topic.