From the description of the plugin "Hide Featured Image":

There are instances when one wants to show featured image on single post and hide it on another post. This plugin will allow you to show or hide featured image from single post page.

Indeed there are such instances, including with custom post types, but unfortunately the solution from the plugin, shown below, is a css solution that just hides the featured image instead of programmatically "dequeuing" or disabling it:

function sh_featured_image() {
    if( is_single() || is_page() ){

      $hide = false;
      $sh_hide_all = get_option('sh_hide_all_image');/* Hide all post or image */
      $hide_image =  get_post_meta( get_the_ID(), '_hide_featured', true );/* Hide single post */

      $hide = ( is_page() && isset( $sh_hide_all['page_image'] ) && $sh_hide_all['page_image'] && $hide_image != 2 ) ? true : $hide ; 
      $hide = ( is_singular( 'post' ) && isset( $sh_hide_all['post_image'] ) && $sh_hide_all['post_image'] && $hide_image != 2 ) ? true : $hide ; 
      $hide = ( isset( $hide_image ) && $hide_image && $hide_image != 2 )? true : $hide;/* Hide single post */
      if( $hide ){ ?>
          .has-post-thumbnail img.wp-post-image, 
          .attachment-twentyseventeen-featured-image.wp-post-image { display: none !important; }          


Obviously, the css selector .attachment-twentyseventeen-featured-image.wp-post-image only pertains to the Twenty Seventeen theme, whereas the css selector .has-post-thumbnail img.wp-post-image is more generic.

In my concrete use case, the featured image should not be shown on individual custom post type pages, but it should be shown on category pages listing all the items of the custom post type.

Is it possible to programmatically disable or "dequeue" the featured image on certain pages/posts rather than simply hiding it with css without editing any of the theme templates (or creating a new one)?

1 Answer 1


It is definitely possible. We may need more info though. Do you know how to use page templates? Copy your single.php (or your page.php) from your theme and name it single-your-cpt-slug.php. (Replace 'your-cpt-slug' with your actual cpt slug). Within this file remove the call to the featured image. This is a pretty generic answer without knowing more about your setup or what your code looks like.

  • Yes, I'm quite familiar with page templates, but let me rephrase my question this way: In WooCommerce, you would do something like this: remove_action('woocommerce_before_single_product_summary', 'woocommerce_show_product_images', 20 ); add_action( 'woocommerce_before_single_product_summary', '[custom function]', 20 ); Does WP have a similar action hook or filter?
    – Miqi180
    Mar 24, 2022 at 0:27
  • There's not a catch-all hook for this in wordpress. Every theme could do this a different way and it would rely on how that theme developer has decided to include or NOT include a method to do this. I know of several themes that do include something along the lines of what you're asking here, but all do it differently. IMHO the ideal way is to just pull it out in the template. Is there a reason you don't want to do it that way?
    – rudtek
    Mar 24, 2022 at 3:00
  • Thanks for your insights. I just think it would be a lot cleaner to do it "the WooCommerce way" if that were possible, but if this is theme-dependent then editing/creating templates is probably the correct way to go, unless the theme happens to have built-in functions for this.
    – Miqi180
    Mar 24, 2022 at 10:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.