Community Forums › Forums › Archived Forums › Design Tips and Tricks › How to add the featured image to a single post in Genesis 2.0
Tagged: featured image, genesis 2.0
- This topic has 4 replies, 2 voices, and was last updated 12 years, 3 months ago by
Vladislav Melnik.
-
AuthorPosts
-
July 10, 2013 at 8:20 am #50100
Vladislav Melnik
MemberHey 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
http://test.affendeal.de
VladislavJuly 10, 2013 at 11:12 pm #50210Derek
MemberTry 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 pluginJuly 11, 2013 at 1:17 am #50215Vladislav Melnik
MemberHi 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?
July 11, 2013 at 7:49 am #50237Derek
MemberWill 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 pluginJuly 23, 2013 at 10:36 am #52085Vladislav Melnik
MemberHey Derek,
forgot to say thank you... so, THANK YOU!
Helped, everything is cool now! 🙂
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.