0
X
Add Snippet To Project
New Project
Add To Existing Project
/**
* Registers a custom post type 'videos'.
*
* @since 1.0.0
*
* @return void
*/
function register_video_cpt() : void {
$labels = [
'name' => _x( 'Videos', 'Post Type General Name', 'hausted' ),
'singular_name' => _x( 'Video', 'Post Type Singular Name', 'hausted' ),
'menu_name' => __( 'Videos', 'hausted' ),
'name_admin_bar' => __( 'Videos', 'hausted' ),
'archives' => __( 'Videos Archives', 'hausted' ),
'attributes' => __( 'Videos Attributes', 'hausted' ),
'parent_item_colon' => __( 'Parent Video:', 'hausted' ),
'all_items' => __( 'All Videos', 'hausted' ),
'add_new_item' => __( 'Add New Video', 'hausted' ),
'add_new' => __( 'Add New', 'hausted' ),
'new_item' => __( 'New Video', 'hausted' ),
'edit_item' => __( 'Edit Video', 'hausted' ),
'update_item' => __( 'Update Video', 'hausted' ),
'view_item' => __( 'View Video', 'hausted' ),
'view_items' => __( 'View Videos', 'hausted' ),
'search_items' => __( 'Search Videos', 'hausted' ),
'not_found' => __( 'Video Not Found', 'hausted' ),
'not_found_in_trash' => __( 'Video Not Found in Trash', 'hausted' ),
'featured_image' => __( 'Featured Image', 'hausted' ),
'set_featured_image' => __( 'Set Featured Image', 'hausted' ),
'remove_featured_image' => __( 'Remove Featured Image', 'hausted' ),
'use_featured_image' => __( 'Use as Featured Image', 'hausted' ),
'insert_into_item' => __( 'Insert into Video', 'hausted' ),
'uploaded_to_this_item' => __( 'Uploaded to this Video', 'hausted' ),
'items_list' => __( 'Videos List', 'hausted' ),
'items_list_navigation' => __( 'Videos List Navigation', 'hausted' ),
'filter_items_list' => __( 'Filter Videos List', 'hausted' ),
];
$labels = apply_filters( 'videos-labels', $labels );
$args = [
'label' => __( 'Video', 'hausted' ),
'description' => __( 'Videos', 'hausted' ),
'labels' => $labels,
'supports' => [
'title',
'editor',
'thumbnail',
'revisions',
'custom-fields',
'page-attributes',
'post-formats',
],
'taxonomies' => [
'video_categories',
],
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => 5,
'menu_icon' => 'dashicons-admin-post',
'show_in_admin_bar' => true,
'show_in_nav_menus' => true,
'exclude_from_search' => false,
'has_archive' => true,
'can_export' => true,
'capability_type' => 'post',
'show_in_rest' => true,
];
$args = apply_filters( 'videos-args', $args );
register_post_type( 'videos', $args );
}
add_action( 'init', 'register_video_cpt', 0 );
videos cpt