0
X
Add Snippet To Project
New Project
Add To Existing Project
/**
* Registers a custom post type 'ebooks'.
*
* @since 1.0.0
*
* @return void
*/
function wpturbo_register_custom_ebooks_post_type() : void {
$labels = [
'name' => _x( 'eBooks', 'Post Type General Name', 'wpturbo' ),
'singular_name' => _x( 'eBook', 'Post Type Singular Name', 'wpturbo' ),
'menu_name' => __( 'eBooks', 'wpturbo' ),
'name_admin_bar' => __( 'eBooks', 'wpturbo' ),
'archives' => __( 'eBooks Archives', 'wpturbo' ),
'attributes' => __( 'eBooks Attributes', 'wpturbo' ),
'parent_item_colon' => __( 'Parent eBook:', 'wpturbo' ),
'all_items' => __( 'All eBooks', 'wpturbo' ),
'add_new_item' => __( 'Add New eBook', 'wpturbo' ),
'add_new' => __( 'Add New', 'wpturbo' ),
'new_item' => __( 'New eBook', 'wpturbo' ),
'edit_item' => __( 'Edit eBook', 'wpturbo' ),
'update_item' => __( 'Update eBook', 'wpturbo' ),
'view_item' => __( 'View eBook', 'wpturbo' ),
'view_items' => __( 'View eBooks', 'wpturbo' ),
'search_items' => __( 'Search eBooks', 'wpturbo' ),
'not_found' => __( 'eBook Not Found', 'wpturbo' ),
'not_found_in_trash' => __( 'eBook Not Found in Trash', 'wpturbo' ),
'featured_image' => __( 'Featured Image', 'wpturbo' ),
'set_featured_image' => __( 'Set Featured Image', 'wpturbo' ),
'remove_featured_image' => __( 'Remove Featured Image', 'wpturbo' ),
'use_featured_image' => __( 'Use as Featured Image', 'wpturbo' ),
'insert_into_item' => __( 'Insert into eBook', 'wpturbo' ),
'uploaded_to_this_item' => __( 'Uploaded to this eBook', 'wpturbo' ),
'items_list' => __( 'eBooks List', 'wpturbo' ),
'items_list_navigation' => __( 'eBooks List Navigation', 'wpturbo' ),
'filter_items_list' => __( 'Filter eBooks List', 'wpturbo' ),
];
$labels = apply_filters( 'ebooks-labels', $labels );
$args = [
'label' => __( 'eBook', 'wpturbo' ),
'description' => __( 'eBooks That Visitors Can Download', 'wpturbo' ),
'labels' => $labels,
'supports' => [
'title',
'excerpt',
],
'taxonomies' => [
'category',
],
'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,
'publicly_queryable' => true,
'exclude_from_search' => false,
'has_archive' => true,
'can_export' => true,
'rewrite' => [
'slug' => 'ebook',
'with_front' => true,
'pages' => true,
'feeds' => true,
],
'capability_type' => 'page',
'show_in_rest' => true,
'rest_base' => 'ebooks',
'rest_controller_class' => 'WP_REST_ebooks_Controller',
];
$args = apply_filters( 'ebooks-args', $args );
register_post_type( 'ebooks', $args );
}
add_action( 'init', 'wpturbo_register_custom_ebooks_post_type', 0 );