How to add the featured image to a single post in Genesis 2.0

Community Forums Forums Design Tips and Tricks How to add the featured image to a single post in Genesis 2.0

This topic is: not resolved

This topic contains 4 replies, has 2 voices, and was last updated by  Vladislav Melnik 1 year, 4 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #50100

    Vladislav Melnik
    Participant
    Post count: 4

    Hey guys,

    I’m getting crazy.

    I can’t find a solution for my simple problem – how to add featured images to single posts in Genesis 2.0?

    You can see here that on the homepage everything is fine. But on a single post there is no featured image.

    I already searched Google and the “StudioPress Database” but couldn’t find anything useful.

    Hope you can help me? :)

    Greetings
    Vladislav

    http://test.affendeal.de
    #50210

    Derek
    Participant
    Post count: 46

    Try adding this to your functions.php file:

    /** Add Featured Image Above Post Content on Posts */
    function image_before_post_content() {
    if( is_single() )
    	echo '<div class="featured-image-single">' . get_the_post_thumbnail($thumbnail->ID) . '</div><!-- end .featured-image-single -->';
    }
    add_action('genesis_before_post_content', 'image_before_post_content');

    You might need to add some additional code to your style.css file depending on how you want the image to be displayed. The function above wraps the image in the .featured-image-single class.

    .featured-image-single {
    	margin: 0 0 2.4rem;
    	/* etc. */
    }

    Derek Rippe – CSS Artist & Genesis Fanboy @ SynaVista and MediaCairn Design Studio
    Figure out your CSS problems with Firebug | Check out my Custom Comment Form Title plugin

    #50215

    Vladislav Melnik
    Participant
    Post count: 4

    Hi Derek,

    thanks for your response!

    In works fine in the test environment (just replaced the old hook genesis_before_post_content with genesis_entry_header).

    But if you take a look at the live environment, you’ll see the thumbnail is only 50px x 50px.

    Do you know why?

    #50237

    Derek
    Participant
    Post count: 46

    Will the featured image always be the same size? If so, you could try adding those dimensions to the function that gets the image:

    get_the_post_thumbnail($post_id, array(590,215) );

    More information on the get_the_post_thumbnail(); function can be found here: http://codex.wordpress.org/Function_Reference/the_post_thumbnail

    You might also be able to force it in the CSS:

    .featured-image-single {
    	display: block;
            height: 215px;
            width: 520px;
    }

    Sometimes I’ve had issues with image sizes if WordPress hasn’t (for whatever reason) resized the image to the right size when I originally uploaded it. Regenerating the Thumbnails usually fixes that (it’s easy to try).


    Derek Rippe – CSS Artist & Genesis Fanboy @ SynaVista and MediaCairn Design Studio
    Figure out your CSS problems with Firebug | Check out my Custom Comment Form Title plugin

    #52085

    Vladislav Melnik
    Participant
    Post count: 4

    Hey Derek,

    forgot to say thank you… so, THANK YOU!

    Helped, everything is cool now! :)

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

You must be logged in to reply to this topic.