add featured image to single post modern portfolio theme

Community Forums Forums Design Tips and Tricks add featured image to single post modern portfolio theme

This topic is: resolved

This topic contains 4 replies, has 2 voices, and was last updated by  dmcleod87 7 months, 2 weeks ago.

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

    dmcleod87
    Participant
    Post count: 53

    hi all,

    am trying to get the featured image to appear on a single post page in the modern portfolio theme. i want it to appear below the post title but above the post content. this is the code i am using but it doesn’t work.

    /** Add Featured Image Above Post Content on Posts */
    add_action( 'genesis_entry_header', 'single_post_featured_image', 15 );
    
    function single_post_featured_image() {
    	
    	if ( ! is_singular( 'post' ) )
    		return;
    	
    	$img = genesis_get_image( array( 'format' => 'html', 'size' => genesis_get_option( 'image_size' ), 'attr' => array( 'class' => 'post-image' ) ) );
    	printf( '<a href="%s" title="%s">%s</a>', get_permalink(), the_title_attribute( 'echo=0' ), $img );
    }

    can anyone tell me what i’m doing wrong? i used this code on another site (based on genesis sample theme) and it works…

    thanks!

    http://www.portfolio.dylanmcleod.net.au/threaded-comments/
    #83714

    braddalton
    Participant
    Post count: 9223

    Only works on HTML themes as it uses the new loop hooks.


    Specializing In StudioPress Child Theme Customization.
    500+ StudioPress Tutorials

    #83733

    dmcleod87
    Participant
    Post count: 53

    ok thanks brad. found this code snippet and it works perfectly for anyone else looking to do the same.

    /** Add Post image before post content, single posts only */
    add_action( 'genesis_before_post_content', 'child_post_image' );
    function child_post_image() {
    
    if ( is_category() ) return;
    if ( $image = genesis_get_image( 'format=url&size=post-image' ) ) {
    printf( '<a href="%s" rel="bookmark"><img class="post-photo" src="%s" alt="%s" /></a>', get_permalink(), $image, the_title_attribute( 'echo=0' ) );
    }
    }
    #83804

    braddalton
    Participant
    Post count: 9223

    Please link to the source when you re-publish other peoples website content. Thanks http://wpsites.net/web-design/add-remove-image-above-post-title/


    Specializing In StudioPress Child Theme Customization.
    500+ StudioPress Tutorials

    #83885

    dmcleod87
    Participant
    Post count: 53

    sorry brad will do in future!

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

You must be logged in to reply to this topic.