Featured Image auto insert into posts

  • Learning21st

    #6316

    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?

    Prasanna SP

    #33969

    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(); ?>
    </span>
    <?php
    }
    add_action('graphene_before_post_content','featured_img_thumb');

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

    Learning21st

    #33970

    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.

    Prasanna SP

    #33971

    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.