• 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

Unwanted featured image being displayed

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 › Unwanted featured image being displayed

This topic is: resolved
  • This topic has 13 replies, 5 voices, and was last updated 3 years, 7 months ago by Jay.
Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • January 4, 2014 at 3:52 pm #83253
    Matthew
    Participant

    I'm updating my website to use the Streamline Pro child theme. The theme shows the featured image immediately prior to the post content. I expected that if I remove the featured image, it would no longer be displayed, but for some reason it is. In some way the featured image, which I have removed in the post editor, is still associated with the post.

    I guess this is the section of code in the functions.php that I will need to amend somehow. Can anyone explain what's going on?

    //* Remove default post image
    remove_action( 'genesis_entry_content', 'genesis_do_post_image', 8 );
    
    //* Add post image above post title
    add_action( 'genesis_entry_header', 'streamline_post_image', 1 );
    function streamline_post_image() {
    
    	if ( is_page() || ! genesis_get_option( 'content_archive_thumbnail' ) )
    		return;
    	
    	if ( $image = genesis_get_image( array( 'format' => 'url', 'size' => genesis_get_option( 'image_size' ) ) ) ) {
    		printf( '<a href="%s" rel="bookmark"><img class="post-photo" src="%s" alt="%s" /></a>', get_permalink(), $image, the_title_attribute( 'echo=0' ) );
    	}
    	
    }
    
    http://test.goldsbrough.biz
    January 4, 2014 at 3:59 pm #83255
    Brad Dalton
    Participant

    Try removing that code.


    Tutorials for StudioPress Themes.

    January 4, 2014 at 4:04 pm #83258
    Matthew
    Participant

    Brad, I do want the featured image to be displayed if it is there.

    January 4, 2014 at 4:07 pm #83259
    Brad Dalton
    Participant

    Before or after the title?


    Tutorials for StudioPress Themes.

    January 4, 2014 at 4:20 pm #83261
    Brad Dalton
    Participant

    By default, it displays before the entry meta which is before the title.

    You can reposition the image simply by changing the hook and/or 3rd parameter which is 1

    add_action( 'genesis_entry_header', 'streamline_post_image', 1 );
    

    If you change the 1 to 11, it will display after the title and before the content

    Here's the hook guide.


    Tutorials for StudioPress Themes.

    January 4, 2014 at 6:42 pm #83283
    Matthew
    Participant

    I'll try to make my question clearer. I'm not wanting to reposition the featured image.

    • I have a post with a featured image.
    • The featured image is shown with the post.
    • I remove the featured image.
    • The featured image is still shown with the post.

    My question is, why is the featured image still displayed when it is no longer associated with the post?

    January 6, 2014 at 2:22 am #83551
    Matthew
    Participant

    Anyone?

    January 6, 2014 at 9:55 am #83592
    Summer
    Member

    Are you using the Featured Image meta box in the edit panel, or did you embed an image in the body of the post?

    There's a behavioral quirk in Genesis where it will take the first post image and make it the featured image by default if you do not specify one, whether you want it to or not.

    Gary Jones said that as of Genesis 2.0, there's a hook to turn this behavior off. He wrote a filter snippet to do that, and he also helped me write a plugin to shut this behavior off as well.

    See long discussion here: http://www.studiopress.community/topic/no-need-for-featured-image-in-pro-themes/


    WordPress / Genesis Site Design & Troubleshooting: A Touch of Summer | @SummerWebDesign
    Slice of SciFi | Writers, After Dark

    January 6, 2014 at 4:58 pm #83672
    Matthew
    Participant

    Hi, Summer,

    Thanks for pointing me in the direction of that thread. It discusses exactly the problem I'm having.

    My first attempt to use the code snippet from GitHub didn't work properly. I'll take another look tomorrow.

    January 7, 2014 at 12:10 pm #83847
    Matthew
    Participant

    OK, I'm stumped and could do with some more help...

    To recap...

    • - I'm using the Streamline Pro theme.
    • - If I've attached a featured image, I want it to be shown at the top of the post.
    • - If I haven't attached a featured image, I don't want an image to be shown there (and I especially don't want a random image from within the post to be treated as if it's a 'featured image'.

    The theme uses this code to show an image for the post.

    
    //* Remove default post image
    remove_action( 'genesis_entry_content', 'genesis_do_post_image', 8 );
    
    //* Add post image above post title
    add_action( 'genesis_entry_header', 'streamline_post_image', 1 );
    function streamline_post_image() {
    
    	if ( is_page() || ! genesis_get_option( 'content_archive_thumbnail' ) )
    		return;
    	
    	if ( $image = genesis_get_image( array( 'format' => 'url', 'size' => genesis_get_option( 'image_size' ) ) ) ) {
    		printf( '<a href="%s" rel="bookmark"><img class="post-photo" src="%s" alt="%s" /></a>', get_permalink(), $image, the_title_attribute( 'echo=0' ) );
    	}
    	
    }
    

    I've taken the code by Gary Jones...

    
    add_filter( 'genesis_get_image', 'prefix_stop_auto_featured_image' );
    /**
     * Stop Genesis archives from using first attached image as fallback when no featured image is set.
     *
     * @param  array $args Default image arguments.
     *
     * @return array       Amended default image arguments.
     */
    function prefix_stop_auto_featured_image( $args ) {
    	if ( ! isset( $args['context'] ) || 'archive' !== $args['context'] )
    		return $args;
    	$args['fallback'] = false;
    	return $args;
    }
    

    ... and placed it in the functions.php file before the code that came with the theme. That didn't work, so I modified Gary's code in several ways, none of which worked.

    I'm exhausted! Help!!!

    January 7, 2014 at 4:22 pm #83888
    Summer
    Member

    What I did in the plugin that Gary helped me write was modify the above code so that it always eliminated the fallback image:

    //* Disable Fallback functionality
    add_filter( 'genesis_get_image_default_args', 'prefix_stop_auto_featured_image' );
    function prefix_stop_auto_featured_image( $args ) {
    	$args['fallback'] = false;
    	return $args;
    }

    Try adding it after the code that moves the image location, and without the conditional. It's worked beautifully on several test sites I've played with it on.

    One caveat, this only works with Genesis 2.0 and above. It will not work with 1.9.2 or earlier because the hook/filter wasn't there.


    WordPress / Genesis Site Design & Troubleshooting: A Touch of Summer | @SummerWebDesign
    Slice of SciFi | Writers, After Dark

    January 7, 2014 at 11:14 pm #83943
    Matthew
    Participant

    Thanks, Summer, that's working nicely.

    January 20, 2014 at 7:07 pm #86206
    caseym
    Member

    Hi Summer. Just want to say thank you for posting that solution. I had the exact problem and was able to fix it. 🙂

    Casey

    August 25, 2019 at 1:18 pm #493168
    Jay
    Member

    This is now 2019. I was having the same issue.
    Thank you Summer.

    It worked perfectly!

    Jay

  • Author
    Posts
Viewing 14 posts - 1 through 14 (of 14 total)
  • The topic ‘Unwanted featured image being displayed’ is closed to new replies.

CTA

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

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2023 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