WP Smith

Creating WordPress & Genesis Websites Since 2010

  • Home
  • About
  • Services
  • Blog
  • Contact

Apr 30 2012

How to Prevent Featured Images in Custom Post Types

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.

Written by Travis Smith · Categorized: Genesis

StudioPress Premium WordPress Themes     WP Engine Managed WordPress Hosting

What can I do for you!?

Custom Development

We develop plugins by determining both business/functional and technical requirements, following WordPress development best practices, and using agile methodology to ensure you get the best solution.

Consulting

Have questions? Need a reliable developer to consult? Please contact us today!

Customized Theme

We can customize your theme or child theme, or create a child theme for you based on your needs while enhancing the performance of every individual attribute.

Customized Plugin

We can customize your plugins, extend plugins (e.g., Gravity Forms, Jetpack, Soliloquy) based on your needs ensuring security, performance, and positive business impact.

Contact Us

About Travis Smith

As a WordPress enthusiast, developer, and speaker, Travis writes about what he learns in WordPress trying to help other WordPress travelers, beginners and enthusiasts with tutorials, explanations, & demonstrations.

Comments

  1. Scott says

    February 23, 2013 at 3:14 am

    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.

    Reply
  2. lekhapotro says

    September 22, 2014 at 1:34 am

    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?

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  • Twitter
  • Facebook
  • LinkedIn
  • Google+
  • RSS

Copyright © 2025 � WP Smith on Genesis on Genesis Framework � WordPress � Log in