• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

add featured image to single post modern portfolio theme

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

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

This topic is: resolved
  • This topic has 4 replies, 2 voices, and was last updated 12 years, 5 months ago by dmcleod87.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • January 6, 2014 at 6:35 pm #83689
    dmcleod87
    Member

    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/
    January 6, 2014 at 8:49 pm #83714
    Brad Dalton
    Participant

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


    Tutorials for StudioPress Themes.

    January 6, 2014 at 9:45 pm #83733
    dmcleod87
    Member

    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' ) );
    }
    }
    January 7, 2014 at 9:11 am #83804
    Brad Dalton
    Participant

    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/


    Tutorials for StudioPress Themes.

    January 7, 2014 at 4:08 pm #83885
    dmcleod87
    Member

    sorry brad will do in future!

  • Author
    Posts
Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘Design Tips and Tricks’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2026 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble