How to show Specified Featured Image Only and not Post Images

Community Forums Forums Design Tips and Tricks How to show Specified Featured Image Only and not Post Images

This topic is: not resolved

This topic contains 15 replies, has 6 voices, and was last updated by  Summer 1 month, 2 weeks ago.

Viewing 15 posts - 1 through 15 (of 16 total)
  • Author
    Posts
  • #54526

    francky
    Participant
    Post count: 41

    I’m using Epik Theme and when I enable “featured images”, posts that do not have featured images show post images as featured images on front/blog page!
    I would like to show featured images only for posts that I specified featured images. Other posts’ images shouldn’t show as featured images.

    I shall appreciate any support.
    Thank you.

    #54557

    Summer
    Participant
    Post count: 1092

    This was a Genesis feature I always thought had been implemented backwards. Why not disable the default post image instead of disabling the Featured Image? When people add a specific Featured Image, that’s what they want to display.

    99% of the time, if they don’t add one, it means they really may not have wanted one so don’t assume otherwise and use the first post image as a fallback. That’s probably not what they wanted, especially in cases where the first post image is too small to resize to what the featured image size is.

    I think you’d have to disable Display Featured Image in the Genesis settings, and also remove the default function and replace it with a new function that does the Featured Image a little bit smarter.


    #54560

    francky
    Participant
    Post count: 41

    And that’s what I’m asking! How can do that?

    #54695

    Summer
    Participant
    Post count: 1092

    I’ve seen a code snippet in the past that accomplished something similar, but now I can’t recall if it was from Greg Rickaby or somewhere on WP Beginner… I just can’t seem to find it now!

    This is rough, but I think it’d be something along these lines:

    
    // Change featured image
    remove_action ( 'genesis_post_content', 'genesis_do_post_image' );
    add_action ( 'genesis_post_content', 'child_do_post_image' ) ;
    function child_do_post_image() {
    // conditional to determine if the actual featured image is set, go away if not
    // code here to grab and print out that image
    }
    

    I’ll keep searching, and if I find it I’ll post it…


    #54982

    Summer
    Participant
    Post count: 1092

    I found Greg Rickaby’s snippet that might serve as a guide to creating the needed functionality here:

    http://gregrickaby.com/genesis-code-snippets/

    
    /** Add custom post image above post title */
    add_action( 'genesis_before_post_content', 'generate_post_image', 5 );
    function generate_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-image" src="%s" alt="%s" /></a>', get_permalink(), $image, the_title_attribute( 'echo=0' ) );
    	}
    
    }
    

    I also noticed you were asking the same question on the Appfinite forums… hopefully with a better explanation of the needed solution, Eric might be able to whip up the right code faster than I.


    #55601

    francky
    Participant
    Post count: 41

    Hello Summer!

    I greatly appreciate your help in resolving this.
    I have implemented the code above but what it does is that, it adds another the featured image/post image on top of the existing one. So I’m kind of having double images for each post display!

    #55634

    trump
    Participant
    Post count: 7

    Hi francky and Summer

    Thanks to you both, I got rid of the “featured image above post title.”

    First I removed the below code from functions.php and then activated “Include the Featured Image?” in Genesis Content Archives. Here’s my blog if francky wants to check before making the change.

    /** Add custom post image above post title */
    add_action( ‘genesis_before_post_content’, ‘generate_post_image’, 5 );
    function generate_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( ‘%s‘, get_permalink(), $image, the_title_attribute( ‘echo=0′ ) );
    }

    }

    • This reply was modified 1 year, 1 month ago by  trump.
    • This reply was modified 1 year, 1 month ago by  trump.
    • This reply was modified 1 year, 1 month ago by  trump.
    • This reply was modified 1 year, 1 month ago by  trump.
    #55720

    francky
    Participant
    Post count: 41

    Hi Trump!

    Thank you for your consideration!

    I don’t have that code in my function.php and activating “Include the Featured Image?” gives the same results. i.e.Show Featured image for posts with specified featured image and post image(s) for posts without specified featured image. Which is of course strange!

    I wonder why in the first place did you have to put that code in your function.php only to remove it later!

    #55765

    trump
    Participant
    Post count: 7

    Hi francky

    I’m using Decor theme and the code came with it. Your theme have to have a similar code (I think) for it to show a featured image. Decor theme works exactly the way you described with featured post images.

    For me by putting together what you and Summer was discussing solved the issue. Good luck with your efforts to find a solution!

    #57057

    francky
    Participant
    Post count: 41

    I still haven’t been able to solve the matter!

    Someone please help!

    #57058

    tornado
    Participant
    Post count: 25

    Hi francky.

    I have had a similar issue with post images displaying as featured images on category blog pages. I used the code here.

    but it doens’t work on HTML5-converted sites. It also suggests placing in the page_blog.php file which is a bit naughty as Genesis core files should not be touched. Still, it did work before my site was converted.

    Like you, I’m still looking for a solution. This topic is firmly on my radar!

    G

    #109785

    Cletus
    Member
    Post count: 7

    Hi, sorry to drag this up but thought it would be better to rather than starting a new thread.

    Did anyone ever find a solution to this?

    thanks

    • This reply was modified 3 months, 1 week ago by  Cletus.
    • This reply was modified 3 months, 1 week ago by  Cletus.
    #117808

    axntdsgn
    Member
    Post count: 2

    I’m having the same issue. I added code to my base Genesis theme to add featured images to single pages and posts, but there are times I don’t want to use a featured image, and only have images placed in the body of the page.

    I looked for a solution and found numerous references to WordPress having, as default behavior, the first image in a post is used as the featured image, if a featured image is not set. So it looks like it’s not only related to Genesis.

    Anyone have a solution to disable this “feature”?

    #117813

    Summer
    Participant
    Post count: 1092

    Are you sure about WP using that behavior? I just checked on one of my test sites, and WordPress does not use the first post image as a featured image, at least not in 3.8 and 3.9 with the default standalone themes.

    But as of Genesis 2.0, there is a filter that will allow you to turn off that feature. You can include that filter in your functions.php, and I wrote a plugin for myself to do that on a handful of my own sites.

    see lengthy discussion here:

    http://www.studiopress.com/forums/topic/no-need-for-featured-image-in-pro-themes/

    and see Brad’s snippet solution here:

    http://wpsites.net/web-design/prevent-genesis-2-0-archives-from-using-first-image-in-content-area-as-featured-image/


    #117821

    axntdsgn
    Member
    Post count: 2

    Ahh, adding the code to the functions file worked. Thanks!!

    About default WP behavior, my search for a solution kept coming up with people saying it was WP’s behavior, so I assumed it was so. Perhaps it was true at some point, but not so now? In any event, thanks for the fix.

Viewing 15 posts - 1 through 15 (of 16 total)

You must be logged in to reply to this topic.