1

The Featured Image Box is not showing inside the WP admin area for my custom post type (in normal post it does).

Things i've already done: add the theme support within action hook with after_setup_theme

// Register Theme Features
function custom_theme_features()  {

    // Add theme support for Post Formats
    add_theme_support( 'post-formats', array( 'video' ) );

    // Add theme support for Featured Images
    add_theme_support( 'post-thumbnails' );
    add_theme_support( 'post-thumbnails', array( 'customposttypename' ) );

     // Set custom thumbnail dimensions
    // set_post_thumbnail_size( 300, 300, true );

    // Add theme support for HTML5 Semantic Markup
    add_theme_support( 'html5', array( 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption' ) );

    // Add theme support for document Title tag
    add_theme_support( 'title-tag' );
}
add_action( 'after_setup_theme', 'custom_theme_features' );

And inside the register_post_type i added to supports the thumbnail value.

Like this:

function mp_cpt_mycustomposttype() {

    $labels = array(
        'name'                  => 'TheName',
        '...'
    );
    $args = array(
        'label'                 => 'TheName',
        'description'           => 'TheNamePlural',
        'labels'                => $labels,
        'supports'              => array( 'title', 'editor', 'excerpt', 'thumbnail', 'custom-fields', ),
        'hierarchical'          => false,
        'public'                => true,
        'show_ui'               => true,
        'show_in_menu'          => true,
        'menu_position'         => 5,
        'show_in_admin_bar'     => true,
        'show_in_nav_menus'     => false,
        'can_export'            => true,
        'has_archive'           => false,        
        'exclude_from_search'   => false,
        'publicly_queryable'    => true,
        'capability_type'       => 'page',
    );
    register_post_type( 'customposttypename', $args );
}
add_action( 'init', 'mp_cpt_mycustomposttype', 0 );

BUT the box for featured image still won't show at my custom post type. Of course i double and tripple checked over and over again the display options:

display options

(Not) surprisingly the featured image box in the default post type post is there.

Maybe some important information for you: my installation is local and made with Trellis and Bedrock. Don't know if there is an impact. Already tried to deactivate the mu-plugins - without any success.

What the heck am i missing about these little sh*tty box?! Drives me completely insane...

Any help to make this work is really appreciated!

  • Impossible to say without seeing your code & WP setup. Do you have any plugins like Adminimize installed? I suggest going "back to basics" and disabling all plugins to rule them out. If that doesn't work, try reverting to one of the default WP themes with just your CPT code added, to rule out anything in your theme that could be causing it. – FluffyKitten Oct 17 '17 at 1:16
  • Thanks for your reply @FluffyKitten. I've done what you suggested. Made a new installation of WP. Twentyseventeen theme is active - without any plugins. Added my CPT Code and still the same problem. Default post has the featured image, mine CPT not. I don't want to do more about this bug - i'm going to try adding custom meta boxes for that or use advanced custom fields. I need multiple pictures for this CPT anyway.. – jaykobo Oct 17 '17 at 18:00
  • It's not clear to me if you're trying to display the featured image on your CPT listing or single, or both.Do you have a template tag on your CPT single, such as: the_post_thumbnail( ); – Ray Gulick Oct 19 '17 at 23:34
  • Sorry - i missed the most important part. Edited the description and added "The Featured Image Box is not showing *inside the WP admin area" – jaykobo Oct 21 '17 at 15:45
1

I think it's possible the 2 separate enabling statements may be interfering with each other. The purpose of having an array is to combine them into one enabling statement. Try the following in your functions file.

Instead of:

add_theme_support( 'post-thumbnails' ); 
add_theme_support( 'post-thumbnails', array( 'customposttypename' ) ); 

This:

add_theme_support( 'post-thumbnails', array( 'post', 'customposttypename' ) );
|improve this answer|||||
0

Do you have a template tag on your listing page?

Template tag for listing page: get_the_post_thumbnail( $post->ID, 'thumbnail' );

|improve this answer|||||
  • see my comment to your question above. It's not about to display the CPT - its about having the featured image box inside my wp admin area like default posts do. – jaykobo Oct 21 '17 at 15:48
  • In that case, did you check the 'screen options' tab at the top right of the edit screen, and make sure that 'featured image' is checked? – Ray Gulick Oct 21 '17 at 21:47
  • Already did that. There is no check option for the feature image. Thats the whole point. – jaykobo Oct 21 '17 at 23:58
  • Try this, in your functions file. Instead of: add_theme_support( 'post-thumbnails' ); add_theme_support( 'post-thumbnails', array( 'customposttypename' ) ); This: add_theme_support( 'post-thumbnails', array( 'post', 'customposttypename' ) ); – Ray Gulick Oct 22 '17 at 4:33
  • YES! Thats it. Now it works. Great. Thank you so much! – jaykobo Oct 22 '17 at 13:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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