Community Forums › Forums › Archived Forums › General Discussion › Add Featured Image to Posts on Sixteen Nine Pro
- This topic has 10 replies, 2 voices, and was last updated 11 years, 6 months ago by
Marcy.
-
AuthorPosts
-
August 8, 2013 at 9:39 am #54935
scottwyden
MemberMy brain might be fried but I can't for the life of me figure out how to get the featured image to show at the top of a post on a site using Sixteen Nine Pro.
Any advice is appreciated!
http://phototickr.comAugust 8, 2013 at 6:34 pm #55146Marcy
ParticipantThat should be Genesis 2.0 using html5. I modified the code in the link below for html5 and is_single().
Please let me know if it works for you.// Add Post image above post title, single posts only
add_action( 'genesis_entry_content', 'agency_post_image', 8 );
function agency_post_image() {
if (( is_single() ) && ( $image = genesis_get_image( 'format=url&size=post-image' ) )) {
printf( '', get_permalink(), $image, the_title_attribute( 'echo=0' ) );
}
}
// See more at: http://kevinshoffner.com/wordpress/tricks/featured-images-in-any-genesis-theme/
Marcy | Amethyst Website Design | Twitter
August 9, 2013 at 11:21 am #55271scottwyden
MemberI appreciate the reply - the code didn't post correctly though. An image showed up.
August 9, 2013 at 11:28 am #55272Marcy
ParticipantDid I misunderstand? I thought you wanted an image to show up.
Marcy | Amethyst Website Design | Twitter
August 9, 2013 at 11:29 am #55273scottwyden
MemberI do, but please look at the code you pasted above. It's showing a broken image rather then part of the code.
August 9, 2013 at 11:46 am #55278Marcy
ParticipantI don't see a broken image in the code, but it could be because the quote marks didn't paste correctly. I also can't seem to edit the post, so here it is again. I hope I got all the quotes. Is this what you wanted?
add_action( 'genesis_entry_content', 'agency_post_image', 8 ); function agency_post_image() { if (( is_single() ) && ( $image = genesis_get_image( 'format=url&size=post-image' ) )) { printf( '%s', get_permalink(), $image, the_title_attribute( 'echo=0' ) ); } }
Marcy | Amethyst Website Design | Twitter
August 9, 2013 at 11:46 am #55279scottwyden
MemberOh that's odd. This is what i'm seeing: https://www.monosnap.com/image/Dqog6d9uUTdh8LXnVWMa9Ljyf
The new is there now, but unfortunately doesn't work. It just pastes a link at the top of posts.
August 9, 2013 at 12:07 pm #55285Marcy
ParticipantI'm sorry it's not working for you; it works for me. Maybe you can go to the link and get the orignal code?
Here are some more posts to help with images.
http://surefirewebservices.com/development/genesis-framework/using-the-genesis-featured-imageThe first link is nearly exactly the code I pasted above, except that there is a 5 instead of an 8, which would make it load earlier, so try that. Otherwise I don't know what to tell you.
Marcy | Amethyst Website Design | Twitter
August 9, 2013 at 12:49 pm #55295Marcy
ParticipantI'm sorry, I can't get this code to work on the Sixteen Nine Pro theme either.
Make a new post and ask the question again, so someone else will see it's not answered.
Marcy | Amethyst Website Design | Twitter
August 10, 2013 at 3:40 pm #55536Marcy
ParticipantOK. Here it is. This one works on Sixteen Nine Pro. Sorry for the confusion at first. Hope it helps!
add_action( 'genesis_before_entry_content', 'amethyst_add_feature_image' ); function amethyst_add_feature_image() { if ( (is_singular( 'post' )) && (has_post_thumbnail()) ) { genesis_image( array( 'size' => 'amethyst-post-image-size', 'attr' => array('class' => 'aligncenter') ) ); } }
Edit: When pasting code into a code block, in some browsers the underscores disappear, so be sure to copy and paste the code.
Marcy | Amethyst Website Design | Twitter
August 11, 2013 at 1:29 am #55593Marcy
ParticipantThe code didn't paste correctly.
add_action( 'genesis_before_entry_content', 'custom_add_feature_image' ); function custom_add_feature_image() { if ( (is_singular( 'post' ) ) && ( has_post_thumbnail() ) ) { genesis_image( array( 'size' => 'large', 'attr' => array('class' => 'aligncenter') ) ); } }
You want to use 'large' or 'medium' for the 'size' as well.
Edit: Fixing the 2 ampersands that aren't pasting correctly
The code should have && rather than code in the if portion of the code
Marcy | Amethyst Website Design | Twitter
-
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.