Reputation: 113
i am trying to add featured image for the custom post type
i have added the theme support in my theme's functions.php file. the following are the code:
function custom_theme_setup() {
add_theme_support( 'post-formats',array('link','gallery'));
add_theme_support( 'post-thumbnails');
add_theme_support( 'custom-background');
add_theme_support( 'custom-header');
add_theme_support( 'custom-logo');
add_theme_support( 'automatic-feed-links');
// add_theme_support( 'html5');
add_theme_support( 'title-tag');
}
add_action( 'init', 'custom_theme_setup');
i also tried adding the support clause to the register post type section still nothing.
here is the register custom post type code:
function movies_create_post_type() {
register_post_type( 'movies',
array(
'labels' => array(
'name' => __( 'Movies' ),
'singular_name' => __( 'Movie' ),
'supports' => array( 'title', 'editor', 'comments', 'excerpt', 'custom-fields', 'thumbnail' ),
),
'public' => true,
'has_archive' => true,
'menu_icon' => 'dashicons-format-video',
'show_ui' => true,
)
);
}
add_action('init','movies_create_post_type');
i have searched everywhere but cant find a proper solution for this issue.
Note: i can set set featured image for my normal post, issue is with the custom post type. Also i have register custom post type through a plugin which i coded myself.
Thanks in advance.
Upvotes: 0
Views: 1016
Reputation: 4880
In support argument not pass in labels array
'supports' => array( 'title', 'editor', 'comments', 'excerpt', 'custom-fields', 'thumbnail' ),
please check below code
function movies_create_post_type() {
register_post_type( 'movies',
array(
'labels' => array(
'name' => __( 'Movies' ),
'singular_name' => __( 'Movie' )
),
'public' => true,
'supports' => array( 'title', 'editor', 'comments', 'excerpt', 'custom-fields', 'thumbnail' ),
'has_archive' => true,
'menu_icon' => 'dashicons-format-video',
'show_ui' => true,
)
);
}
for more info check register_post_type
Upvotes: 0
Reputation: 1049
try putting supports array outside two indexes just like public has_archive menu_icon show_ui like
function movies_create_post_type() {
register_post_type( 'movies',
array(
'labels' => array(
'name' => __( 'Movies' ),
'singular_name' => __( 'Movie' )
),
'public' => true,
'supports' => array( 'title', 'editor', 'comments', 'excerpt', 'custom-fields', 'thumbnail' ),
'has_archive' => true,
'menu_icon' => 'dashicons-format-video',
'show_ui' => true,
)
);
}
Hope it helps !
Upvotes: 1