Many of the new HTML 5 StudioPress child themes automatically display the first image from the content area as the featured image on all archive pages which can duplicate the image on single posts and archive pages.
Even if you don’t add a featured image to a post, Genesis pulls an image from the post and uses it as a featured image.
Here’s the code in genesis which makes this happen:
//* Check for post image (native WP)
if ( has_post_thumbnail( $args['post_id'] ) && ( 0 === $args['num'] ) ) {
$id = get_post_thumbnail_id( $args['post_id'] );
$html = wp_get_attachment_image( $id, $args['size'], false, $args['attr'] );
list( $url ) = wp_get_attachment_image_src( $id, $args['size'], false, $args['attr'] );
}
//* Else if first-attached, pull the first (default) image attachment
elseif ( 'first-attached' === $args['fallback'] ) {
$id = genesis_get_image_id( $args['num'], $args['post_id'] );
$html = wp_get_attachment_image( $id, $args['size'], false, $args['attr'] );
list( $url ) = wp_get_attachment_image_src( $id, $args['size'], false, $args['attr'] );
}
This is not such a bad thing really however some people prefer this didn’t happen which is why Genesis Developer Gary Jones has worked out one solution.
Update: I’ve also created another solution which you’ll find at the end of this post which checks if a featured image has been added and removes it from single posts if added.
Simply add this code in your child themes functions file and it will stop your theme from using any images from your content area as post thumbnails on your blog, category and other archive pages.
Note: This code (from Gary Jones) is only needed for sites running Genesis 2.0.
Remove this code || 'archive' !== $args['context']
to target single posts.
Note from Gary: The reason for the isset(), is that not all calls to genesis_get_image() may have an argument array that contains a context key, since it was only added in Genesis 2.0.
Alternative Solution
This PHP code once added to the end of your child themes functions file, prevents Genesis from pulling any attachment images from the post content area and displaying them as your featured image before the entry title or on any type of archive page.
The code only displays a featured image which you have set manually using the Featured Image box included on all Edit Post/Page screens.
Was This Tutorial Helpful?