wordpress 将图像添加到分类演员

wordpress add an image to a taxonomy actor

我想将图像添加到我的自定义分类 actor,但当我查看编辑 actor 选项时,它只显示选项名称、slug 和描述。 对于上述问题,我需要在 functions.php 中添加一个选项。

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

我试图在不询问的情况下找出如何实现这一目标,因此感谢您的帮助。

尝试添加supports参数:

'supports' => array( 'thumbnail' ),

例如:

...
        'hierarchical'      => false,
        'show_ui'           => true,
        'show_admin_column' => true,
        'query_var'         => true,
        'rewrite'           => array( 'slug' => 'actor' ),
        'supports'          => array( 'thumbnail' ),
    )
);

详见this guide中的“第5步:函数实现”:

'supports' => array( 'title', 'editor', 'comments', 'thumbnail', 'custom-fields' ) determines the features of the custom post type which is to be displayed.