1/**
2 * Register a custom post type called "book".
3 *
4 * @see get_post_type_labels() for label keys.
5 */
6function wpdocs_codex_book_init() {
7 $labels = array(
8 'name' => _x( 'Books', 'Post type general name', 'textdomain' ),
9 'singular_name' => _x( 'Book', 'Post type singular name', 'textdomain' ),
10 'menu_name' => _x( 'Books', 'Admin Menu text', 'textdomain' ),
11 'name_admin_bar' => _x( 'Book', 'Add New on Toolbar', 'textdomain' ),
12 'add_new' => __( 'Add New', 'textdomain' ),
13 'add_new_item' => __( 'Add New Book', 'textdomain' ),
14 'new_item' => __( 'New Book', 'textdomain' ),
15 'edit_item' => __( 'Edit Book', 'textdomain' ),
16 'view_item' => __( 'View Book', 'textdomain' ),
17 'all_items' => __( 'All Books', 'textdomain' ),
18 'search_items' => __( 'Search Books', 'textdomain' ),
19 'parent_item_colon' => __( 'Parent Books:', 'textdomain' ),
20 'not_found' => __( 'No books found.', 'textdomain' ),
21 'not_found_in_trash' => __( 'No books found in Trash.', 'textdomain' ),
22 'featured_image' => _x( 'Book Cover Image', 'Overrides the “Featured Image” phrase for this post type. Added in 4.3', 'textdomain' ),
23 'set_featured_image' => _x( 'Set cover image', 'Overrides the “Set featured image” phrase for this post type. Added in 4.3', 'textdomain' ),
24 'remove_featured_image' => _x( 'Remove cover image', 'Overrides the “Remove featured image” phrase for this post type. Added in 4.3', 'textdomain' ),
25 'use_featured_image' => _x( 'Use as cover image', 'Overrides the “Use as featured image” phrase for this post type. Added in 4.3', 'textdomain' ),
26 'archives' => _x( 'Book archives', 'The post type archive label used in nav menus. Default “Post Archives”. Added in 4.4', 'textdomain' ),
27 'insert_into_item' => _x( 'Insert into book', 'Overrides the “Insert into post”/”Insert into page” phrase (used when inserting media into a post). Added in 4.4', 'textdomain' ),
28 'uploaded_to_this_item' => _x( 'Uploaded to this book', 'Overrides the “Uploaded to this post”/”Uploaded to this page” phrase (used when viewing media attached to a post). Added in 4.4', 'textdomain' ),
29 'filter_items_list' => _x( 'Filter books list', 'Screen reader text for the filter links heading on the post type listing screen. Default “Filter posts list”/”Filter pages list”. Added in 4.4', 'textdomain' ),
30 'items_list_navigation' => _x( 'Books list navigation', 'Screen reader text for the pagination heading on the post type listing screen. Default “Posts list navigation”/”Pages list navigation”. Added in 4.4', 'textdomain' ),
31 'items_list' => _x( 'Books list', 'Screen reader text for the items list heading on the post type listing screen. Default “Posts list”/”Pages list”. Added in 4.4', 'textdomain' ),
32 );
33
34 $args = array(
35 'labels' => $labels,
36 'public' => true,
37 'publicly_queryable' => true,
38 'show_ui' => true,
39 'show_in_menu' => true,
40 'query_var' => true,
41 'rewrite' => array( 'slug' => 'book' ),
42 'capability_type' => 'post',
43 'has_archive' => true,
44 'hierarchical' => false,
45 'menu_position' => null,
46 'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments' ),
47 );
48
49 register_post_type( 'book', $args );
50}
51
52add_action( 'init', 'wpdocs_codex_book_init' );
1function book_setup_post_type() {
2 $args = array(
3 'public' => true,
4 'label' => __( 'Books', 'textdomain' ),
5 'menu_icon' => 'dashicons-book',
6 );
7 register_post_type( 'book', $args );
8}
9add_action( 'init', 'book_setup_post_type' );
10
1// Register Custom Post Type
2function custom_post_type() {
3
4 $labels = array(
5 'name' => _x( 'Post Types', 'Post Type General Name', 'text_domain' ),
6 'singular_name' => _x( 'Post Type', 'Post Type Singular Name', 'text_domain' ),
7 'menu_name' => __( 'Post Types', 'text_domain' ),
8 'name_admin_bar' => __( 'Post Type', 'text_domain' ),
9 'archives' => __( 'Item Archives', 'text_domain' ),
10 'attributes' => __( 'Item Attributes', 'text_domain' ),
11 'parent_item_colon' => __( 'Parent Item:', 'text_domain' ),
12 'all_items' => __( 'All Items', 'text_domain' ),
13 'add_new_item' => __( 'Add New Item', 'text_domain' ),
14 'add_new' => __( 'Add New', 'text_domain' ),
15 'new_item' => __( 'New Item', 'text_domain' ),
16 'edit_item' => __( 'Edit Item', 'text_domain' ),
17 'update_item' => __( 'Update Item', 'text_domain' ),
18 'view_item' => __( 'View Item', 'text_domain' ),
19 'view_items' => __( 'View Items', 'text_domain' ),
20 'search_items' => __( 'Search Item', 'text_domain' ),
21 'not_found' => __( 'Not found', 'text_domain' ),
22 'not_found_in_trash' => __( 'Not found in Trash', 'text_domain' ),
23 'featured_image' => __( 'Featured Image', 'text_domain' ),
24 'set_featured_image' => __( 'Set featured image', 'text_domain' ),
25 'remove_featured_image' => __( 'Remove featured image', 'text_domain' ),
26 'use_featured_image' => __( 'Use as featured image', 'text_domain' ),
27 'insert_into_item' => __( 'Insert into item', 'text_domain' ),
28 'uploaded_to_this_item' => __( 'Uploaded to this item', 'text_domain' ),
29 'items_list' => __( 'Items list', 'text_domain' ),
30 'items_list_navigation' => __( 'Items list navigation', 'text_domain' ),
31 'filter_items_list' => __( 'Filter items list', 'text_domain' ),
32 );
33 $args = array(
34 'label' => __( 'Post Type', 'text_domain' ),
35 'description' => __( 'Post Type Description', 'text_domain' ),
36 'labels' => $labels,
37 'supports' => false,
38 'taxonomies' => array( 'category', 'post_tag' ),
39 'hierarchical' => false,
40 'public' => true,
41 'show_ui' => true,
42 'show_in_menu' => true,
43 'menu_position' => 5,
44 'show_in_admin_bar' => true,
45 'show_in_nav_menus' => true,
46 'can_export' => true,
47 'has_archive' => true,
48 'exclude_from_search' => false,
49 'publicly_queryable' => true,
50 'capability_type' => 'page',
51 );
52 register_post_type( 'post_type', $args );
53
54}
55add_action( 'init', 'custom_post_type', 0 );