Skip to content

Instantly share code, notes, and snippets.

@guyeshet
Created May 19, 2020 07:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guyeshet/49ac6aa0aaa7a5197c3d663db0744df4 to your computer and use it in GitHub Desktop.
Save guyeshet/49ac6aa0aaa7a5197c3d663db0744df4 to your computer and use it in GitHub Desktop.
function register_book_post_type() {
$args = array (
'label' => esc_html__( 'Books', 'text-domain' ),
'labels' => array(
'menu_name' => esc_html__( 'Books', 'text-domain' ),
'name_admin_bar' => esc_html__( 'Book', 'text-domain' ),
'add_new' => esc_html__( 'Add new', 'text-domain' ),
'add_new_item' => esc_html__( 'Add new Book', 'text-domain' ),
'new_item' => esc_html__( 'New Book', 'text-domain' ),
'edit_item' => esc_html__( 'Edit Book', 'text-domain' ),
'view_item' => esc_html__( 'View Book', 'text-domain' ),
'update_item' => esc_html__( 'Update Book', 'text-domain' ),
'all_items' => esc_html__( 'All Books', 'text-domain' ),
'search_items' => esc_html__( 'Search Books', 'text-domain' ),
'parent_item_colon' => esc_html__( 'Parent Book', 'text-domain' ),
'not_found' => esc_html__( 'No Books found', 'text-domain' ),
'not_found_in_trash' => esc_html__( 'No Books found in Trash', 'text-domain' ),
'name' => esc_html__( 'Books', 'text-domain' ),
'singular_name' => esc_html__( 'Book', 'text-domain' ),
),
'public' => true,
'exclude_from_search' => false,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_nav_menus' => true,
'show_in_admin_bar' => true,
'show_in_rest' => true,
'menu_icon' => 'dashicons-book',
'capability_type' => 'post',
'hierarchical' => false,
'has_archive' => true,
'query_var' => true,
'can_export' => true,
'rewrite_no_front' => false,
'supports' => array(
'title',
'editor',
'thumbnail',
'custom-fields',
),
'rewrite' => true,
);
register_post_type( 'book', $args );
}
add_action( 'init', 'your_prefix_register_post_type' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment