custom post types – Feature image does not displaying in backend
I know this question have been asked a lot of times but I test all the answers found and it does not work.
I have not the “featured image” block in my wordpress admin. When I create a post for example I have not this and neither in the custom post “team”.
So I have created my own theme, I have no plugin yet (no conflict here).
I have this in functions.php :
add_action( 'after_setup_theme', 'mytheme_add_theme_support' );
function mytheme_add_theme_support() {
add_theme_support('custom-header'); //custom header image
add_theme_support( 'post-thumbnails' ); //feature image
} //end function add theme support
And in my custom post type “team” I have this :
'supports' => ['title', 'thumbnail', 'editor'],
My cpt “team” :
add_action('init', 'teams_cpt_init');
function teams_cpt_init() {
register_post_type('team', [
'labels' => [
'name' => _x( 'Teams', 'Post type general name', 'mytheme' ),
'singular_name' => _x( 'Team', 'Post type singular name', 'mytheme' ),
'menu_name' => _x( 'Teams', 'Admin Menu text', 'mytheme' ),
'name_admin_bar' => _x( 'Team', 'Add New on Toolbar', 'mytheme' ),
'add_new' => __( 'Add new team', 'mytheme' ),
'featured_image' => _x( 'Add team picture', 'Overrides the “Featured Image” phrase for this post type. Added in 4.3', 'mytheme' ),
'set_featured_image' => _x( 'Add team picture', 'Overrides the “Set featured image” phrase for this post type. Added in 4.3', 'mytheme' ),
'remove_featured_image' => _x( 'Remove team picture', 'Overrides the “Remove featured image” phrase for this post type. Added in 4.3', 'mytheme' ),
'use_featured_image' => _x( 'Use like feature image', 'Overrides the “Use as featured image” phrase for this post type. Added in 4.3', 'mytheme' ),
...
],
'public' => true,
'has_archive' => true,
'rewrite' => ['slug' => 'team'],
'supports' => ['title', 'thumbnail', 'editor'],
'menu_icon' => 'dashicons-flag',
'show_in_rest' => true,
]);
}
And in my functions.php :
require_once __DIR__ . '/cpt/teams.php';
So I don’t understand why I have not the feature image section in my admin part.
Thanks a lot for your response
Leave an answer