5

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:

// 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') );

3 Answers 3

7

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.

3
  • Ahh ...... duh.
    – Devise
    Oct 13, 2011 at 19:33
  • 3
    So, I've tried doing that also, but for some reason, I can't seem to get the featured image area to show up on my custom post type admin area. I'm not totally sure what's going on... On a side note, and totally unrelated to this post, I'm sorry for replying to this thread as an answer as I can't seem to find "comment".
    – Brian
    Feb 11, 2012 at 3:49
  • Try to disable ACF if you have installed it. Mar 26, 2015 at 15:52
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' );
0

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

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.