2

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
  • Have you checked, if the "author" checkbox is selected in the view options in the top right corner? Dec 7 '16 at 18:10
6

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()

2
  • Thanks. Can I know what exactly author supported added to my content type? Since I am using the post_author anyway and no issue with that, but I don't want any hidden surprise if I enable it...
    – Yoga
    Dec 7 '16 at 18:46
  • Not sure I understand your question 100%, but adding support for author will make the Author column available in the post type listing in the admin and will make the author meta box appear when editing the post. Dec 7 '16 at 18:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.