So recently, someone asked if they could enabled Genesis Featured Images in Genesis > Theme Settings yet "disable" them for custom post types. While there is no option for this, it can be done! This is a rather simple task that can be complicated if post types are mixed and other circumstances. However, let's assume a simple setup.
In functions.php or your core functionality plugin where you created the custom post types, enter this code:
[php]
add_action( 'genesis_before_post_content', 'wps_do_post_image_check' );
/*
* Remove genesis_do_post_image() action if on post type archive of
* a custom post type
*
* @global stdClass $post Post object
* @uses genesis_get_option() Gets the genesis option for content archive thumbnails
*/
function wps_do_post_image_check() {
global $post;
if ( ! is_singular() && genesis_get_option( 'content_archive_thumbnail' ) && is_post_type_archive() && ! in_array( $post->post_type, array( 'page', 'post', 'attachment' ) ) )
remove_action( 'genesis_post_content', 'genesis_do_post_image' );
}
[/php]
NOTE: Though posts, pages, and attachments by default do not have archive pages, I cannot assume that in this code snippet.
Scott says
I just left you a comment on another post and wanted to say that the line 12 remove_action placed directly on my archive-cpt.php worked BEAUTIFULLY to fix my problem. Thanks so much.
lekhapotro says
Hello,
I am working on http://www.codeoffering.com/ . Using my own Genesis child theme. I’ve checked “Include the Featured Image?” . It should have shown the first image of a post. But it’s not showing the first image. If I set featured image, only then it shows that image. But I heard that Genesis automatically picks up the very first image of a post. I do not want to use any plugin.
What’s wrong to my child theme?