Custom post type arguments tell WordPress how to create and show your new content type. They control what features it has and how it behaves.
Custom post type arguments in Wordpress
register_post_type('post_type_name', [ 'labels' => [ 'name' => 'Plural Name', 'singular_name' => 'Singular Name' ], 'public' => true, 'has_archive' => true, 'supports' => ['title', 'editor', 'thumbnail'], 'menu_icon' => 'dashicons-admin-post' ]);
The first argument is the unique name for your post type (lowercase, no spaces).
The second argument is an array of options that control how the post type works and looks.
register_post_type('book', [ 'labels' => [ 'name' => 'Books', 'singular_name' => 'Book' ], 'public' => true, 'has_archive' => true ]);
register_post_type('movie', [ 'labels' => [ 'name' => 'Movies', 'singular_name' => 'Movie' ], 'public' => false, 'show_ui' => true, 'supports' => ['title', 'editor'] ]);
register_post_type('recipe', [ 'labels' => [ 'name' => 'Recipes', 'singular_name' => 'Recipe' ], 'public' => true, 'menu_icon' => 'dashicons-carrot', 'supports' => ['title', 'editor', 'thumbnail', 'comments'] ]);
This code creates a new post type called 'event' that is public, has archive pages, supports title, editor, and thumbnail, and uses a calendar icon in the admin menu.
<?php
function create_custom_post_type() {
register_post_type('event', [
'labels' => [
'name' => 'Events',
'singular_name' => 'Event'
],
'public' => true,
'has_archive' => true,
'supports' => ['title', 'editor', 'thumbnail'],
'menu_icon' => 'dashicons-calendar-alt'
]);
}
add_action('init', 'create_custom_post_type');Always hook your custom post type registration to the 'init' action to ensure WordPress is ready.
Use descriptive labels to make the admin area user-friendly.
Setting 'public' to false hides the post type from the front end but can still show it in admin if 'show_ui' is true.
Custom post type arguments define how your new content type behaves and looks.
Use the 'labels', 'public', 'supports', and 'menu_icon' keys to customize your post type.
Register your post type inside a function hooked to 'init' for proper loading.