Community Forums › Forums › Archived Forums › Design Tips and Tricks › How to show Specified Featured Image Only and not Post Images
Tagged: categories, featured image, first image, pages, posts
- This topic has 15 replies, 6 voices, and was last updated 10 years, 5 months ago by Summer.
-
AuthorPosts
-
August 7, 2013 at 7:31 am #54526franckyMember
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.August 7, 2013 at 9:02 am #54557SummerMemberThis 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.
WordPress / Genesis Site Design & Troubleshooting: A Touch of Summer | @SummerWebDesign
Slice of SciFi | Writers, After DarkAugust 7, 2013 at 9:12 am #54560franckyMemberAnd that's what I'm asking! How can do that?
August 7, 2013 at 2:40 pm #54695SummerMemberI'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...
WordPress / Genesis Site Design & Troubleshooting: A Touch of Summer | @SummerWebDesign
Slice of SciFi | Writers, After DarkAugust 8, 2013 at 10:44 am #54982SummerMemberI 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.
WordPress / Genesis Site Design & Troubleshooting: A Touch of Summer | @SummerWebDesign
Slice of SciFi | Writers, After DarkAugust 11, 2013 at 3:19 am #55601franckyMemberHello 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!August 11, 2013 at 9:50 am #55634trumpMemberHi 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( '', get_permalink(), $image, the_title_attribute( 'echo=0' ) );
}}
August 11, 2013 at 11:12 pm #55720franckyMemberHi 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!
August 12, 2013 at 6:12 am #55765trumpMemberHi 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!
August 17, 2013 at 11:46 am #57057franckyMemberI still haven't been able to solve the matter!
Someone please help!
August 17, 2013 at 11:53 am #57058tornadoParticipantHi 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
June 14, 2014 at 3:31 pm #109785CletusMemberHi, 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
August 8, 2014 at 1:33 pm #117808axntdsgnMemberI'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"?
August 8, 2014 at 2:14 pm #117813SummerMemberAre 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:
and see Brad's snippet solution here:
WordPress / Genesis Site Design & Troubleshooting: A Touch of Summer | @SummerWebDesign
Slice of SciFi | Writers, After DarkAugust 8, 2014 at 3:37 pm #117821axntdsgnMemberAhh, 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.
August 8, 2014 at 6:25 pm #117838SummerMemberNo, WP's default behavior was always correct... a post image is a post image, and a featured image is a featured image. Genesis was the first framework that I know of to add the behavior of taking the first post image and making it the default featured image if one isn't specifically set.
There may have been a standalone theme here or there that chose to make that behavior a feature of the theme, but my first experience with it was in Genesis.
I remember my extreme confusion at discovering this backwards "default" behavior, and my extreme anger at having no way to override it. I have two magazine style sites with YEARS worth of extra images to "work around" this behavior. As of Genesis 2.0, the filter you just used was introduced, and for me and a lot of other Genesis users, there was much rejoicing.
Glad it helps!
WordPress / Genesis Site Design & Troubleshooting: A Touch of Summer | @SummerWebDesign
Slice of SciFi | Writers, After Dark -
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.