For the complete documentation index, see llms.txt. This page is also available as Markdown.

register_acpt_post_type

Register a new custom post type

Register a new custom post type.

Usage

register_acpt_post_type([ 
    'post_name'      => 'cpt', 
    'singular_label' => 'New CPT', 
    'plural_label'   => 'New CPTs', 
    'icon'           => 'admin-appearance',
    'supports'       => [ 
        'title',
        'editor', 
        'comments', 
        'revisions', 
        'trackbacks', 
        'author', 
        'excerpt',
    ], 
    'labels'      => [], 
    'settings'    => [], 
    'permissions' => [],
]);

Parameters

Parameter
Type
Required
Description

post_name

string

Required

The post type slug

singular_label

string

Required

The singular display label. Also accepted as singularLabel

plural_label

string

Required

The plural display label. Also accepted as pluralLabel

icon

string

Optional

The admin menu icon (see Dashicons). Defaults to admin-post

supports

array

Optional

WordPress post type features to enable — see official documentation. Defaults to ['title', 'editor']

labels

array

Optional

Override default generated labels — see official documentation. Auto-generated from singular_label/plural_label when omitted

settings

array

Optional

Additional post type arguments — see official documentation. Auto-generated with sensible defaults when omitted

permissions

array

Optional

Role-based capability overrides for this post type

When icon/supports/labels/settings are omitted entirely, sensible defaults are filled in (matching what the admin UI's creation wizard pre-fills). Explicitly passing an empty array ([]) is respected as-is and does not trigger the defaults.

Return

Type
Description

bool

true if the post type was registered successfully, false on failure

Last updated