问题
I was wanting to add a image to my custom taxonomy actor, but when I look in the edit actor options it only shows the options name, slug & description. I need to add an option in the functions.php for the above mentioned problem.
////////////////////////////////////
// TAXONOMY ACTORS //
////////////////////////////////////
register_taxonomy(
'actor',
array( 'movies' ),
array(
'labels' => array(
'name' => __( 'Actors' ),
'singular_name' => __( 'Actor' ),
'search_items' => __( 'Search Actors' ),
'all_items' => __( 'All Actors' ),
'parent_item' => __( 'Parent Actor' ),
'parent_item_colon' => __( 'Parent Actor:' ),
'view_item' => __( 'View Actor' ),
'edit_item' => __( 'Edit Actor' ),
'update_item' => __( 'Update Actor' ),
'add_new_item' => __( 'Add New Actor' ),
'new_item_name' => __( 'New Actor Name' ),
'menu_name' => __( 'Actor' ),
),
'hierarchical' => false,
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'actor' ),
)
);
I have tried to find out how I would achieve this without asking here, so any help appreciated.
回答1:
Try to add the supports
parameter:
'supports' => array( 'thumbnail' ),
For example:
...
'hierarchical' => false,
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'actor' ),
'supports' => array( 'thumbnail' ),
)
);
For details, see "Step 5: Function Implementation" in this guide:
'supports' => array( 'title', 'editor', 'comments', 'thumbnail', 'custom-fields' )
determines the features of the custom post type which is to be displayed.
来源:https://stackoverflow.com/questions/46375024/wordpress-add-an-image-to-a-taxonomy-actor