Featured Image Panel Missing From Custom Post Type in WordPress 3.2

Upgraded to 3.2 from 3.1 and lost the featured image panel in admin that was running in a custom post type.

add_action( 'init', 'create_my_post_types' );

function create_my_post_types() {
    register_post_type( 'header_image_gallery',
        array(
            'labels' => array(
            'name' => __( 'Header Images' ),
            'singular_name' => __( 'Header Image' ),
            'add_new' => __( 'Add New' ),
            'add_new_item' => __( 'Add New Header Image' ),
            'edit' => __( 'Edit' ),
            'edit_item' => __( 'Edit Header Image' ),
            'new_item' => __( 'New Header Image' ),
            'view' => __( 'View Header Images' ),
            'view_item' => __( 'View Header Images' ),
            'search_items' => __( 'Search Header Images' ),
            'not_found' => __( 'No Header Images found' ),
            'not_found_in_trash' => __( 'No Header Images found in Trash' ),
            'parent' => __( 'Parent Header Images' ),
            ),
            'public' => true,
            'supports' => array('title','thumbnail','revisions')
        )
    );
}

Post thumbnails are registered like so:

Read More
// This theme uses post thumbnails
    add_theme_support( 'post-thumbnails', array('post', 'page') );

Note: The custom posts that were created prior to upgrade work properly on the frontend showing their post thumbnails (just the featured image admin panel is missing).

Also: I’ve gone to the codex and pulled the example custom post type, you’ll notice it should show a featured image > but also does not.

add_action('init', 'codex_custom_init');
function codex_custom_init() 
{
  $labels = array(
    'name' => _x('Books', 'post type general name'),
    'singular_name' => _x('Book', 'post type singular name'),
    'add_new' => _x('Add New', 'book'),
    'add_new_item' => __('Add New Book'),
    'edit_item' => __('Edit Book'),
    'new_item' => __('New Book'),
    'all_items' => __('All Books'),
    'view_item' => __('View Book'),
    'search_items' => __('Search Books'),
    'not_found' =>  __('No books found'),
    'not_found_in_trash' => __('No books found in Trash'), 
    'parent_item_colon' => '',
    'menu_name' => 'Books'

  );
  $args = array(
    'labels' => $labels,
    'public' => true,
    'publicly_queryable' => true,
    'show_ui' => true, 
    'show_in_menu' => true, 
    'query_var' => true,
    'rewrite' => true,
    'capability_type' => 'post',
    'has_archive' => true, 
    'hierarchical' => false,
    'menu_position' => null,
    'supports' => array('title','editor','author','thumbnail','excerpt','comments')
  ); 
  register_post_type('book',$args);
}

If I examine the screen options no featured image option is visible in either example.

* Answered my own question

Perhaps in WP 3.1 you did not have to declare your custom post type when adding theme support but in WP 3.2 you do!

// This theme uses post thumbnails
    add_theme_support( 'post-thumbnails', array('post', 'page','header_image_gallery') );

Related posts

Leave a Reply

3 comments

  1. Change this:

    // This theme uses post thumbnails
    add_theme_support( 'post-thumbnails', array('post', 'page') );
    

    To this:

    // This theme uses post thumbnails
    add_theme_support( 'post-thumbnails' );
    

    The problem is that the array is explicit, when used. So, post-thumbnail support will only be added to post-types included in the array.

    Omit the array, in order to add Theme support for post thumbnails universally.

  2. Try this , It works for me.

    add_theme_support('post-thumbnails');
    add_post_type_support( 'my_product', 'thumbnail' );
    
    function create_post_type() {
        register_post_type( 'my_product',
            array(
                'labels' => array(
                    'name' => __( 'Products' ),
                    'singular_name' => __( 'Product' )
                ),
                'public' => true,
                'has_archive' => true
            )
        );
    }
    add_action( 'init', 'create_post_type' );
    
  3. Find this code on functions.php

        'supports'              => array( ),
    

    Change the code to

        'supports'              => array( 'thumbnail', ),
    

    This solution can be done if you created custom post type in functions.php