I’ve created a custom post type with this code:

register_post_type(
    'custom_type',
    array(
        'labels'              => $labels,
        'description'         => '',
        'public'              => false,
        'publicly_queryable'  => false,
        'exclude_from_search' => true,
        'show_in_nav_menus'   => false,
        'show_ui'             => true,
        'show_in_menu'        => true,
        'show_in_admin_bar'   => true,
        'menu_icon'           => $icon,
        'can_export'          => false,
        'delete_with_user'    => false,
        'hierarchical'        => false,
        'has_archive'         => false,
        'query_var'           => false,
        'capability_type'     => 'custom_type',
        'map_meta_cap'        => true,
        'rewrite'             => false,
        'supports'            => array(
            'title',
            'custom-fields'
        )
    )
);

However, I cannot find the post_author shown on the edit.php, what wrong with this code?

1 Answer
1

The $supports argument should include author for the Author settings to be available for the custom post type:

'supports' => array(
    'title',
    'custom-fields',
    'author'
)

‘supports’ (array) Core feature(s) the post type supports. Serves as an alias for calling add_post_type_support() directly. Core
features include ‘title’, ‘editor’, ‘comments’, ‘revisions’,
‘trackbacks’, ‘author’, ‘excerpt’, ‘page-attributes’, ‘thumbnail’,
‘custom-fields’, and ‘post-formats’. Additionally, the ‘revisions’
feature dictates whether the post type will store revisions, and the
‘comments’ feature dictates whether the comments count will show on
the edit screen. Defaults is an array containing ‘title’ and ‘editor’.

Docs for register_post_type()

Leave a Reply

Your email address will not be published. Required fields are marked *