Search code examples
phpwordpresscustom-taxonomy

wordpress add an image to a taxonomy actor


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.


Solution

  • UPD. My answer is about custom post types, not custom taxonomies. As @betatester07 noted in the comments, the register_taxonomy() function does not have the supports parameter that register_post_type() has. But since the answer is accepted, I can't delete it.

    Here on wordpress.stackexchange.com you can find solutions using the Term Meta or WP plugins.


    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.