wordpress add an image to a taxonomy actor

不打扰是莪最后的温柔 提交于 2019-12-11 06:34:45

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!