I don’t know how to figured out what’s wrong with my code, Why Custom Post Types “Book” doesn’t show on my dashboard, I logged as Admin and I use latest WordPress installed 3.4.1
Here with my code
function codex_custom_init() {
$labels = array(
'name' => _x('Books', 'post type general name'),
'singular_name' => _x('Book', 'post type singular name'),
'add_new' => _x('Add New', 'book'),
'add_new_item' => __('Add New Book'),
'edit_item' => __('Edit Book'),
'new_item' => __('New Book'),
'all_items' => __('All Books'),
'view_item' => __('View Book'),
'search_items' => __('Search Books'),
'not_found' => __('No books found'),
'not_found_in_trash' => __('No books found in Trash'),
'parent_item_colon' => '',
'menu_name' => __('Books')
);
$capabilities = array(
'publish_posts' => 'publish_books',
'edit_posts' => 'edit_books',
'edit_others_posts' => 'edit_others_books',
'delete_posts' => 'delete_books',
'delete_others_posts' => 'delete_others_books',
'read_private_posts' => 'read_private_books',
'edit_post' => 'edit_book',
'delete_post' => 'delete_book',
'read_post' => 'read_book'
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => true,
'capability_type' => 'book',
'capabilities' => $capabilities,
'has_archive' => true,
'hierarchical' => false,
'menu_position' => null,
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments' )
);
register_post_type('book',$args);
}
add_action( 'init', 'codex_custom_init' );
My code is to add new custom post with custom capabilities for usage of members plugin.