Nếu bạn muốn tạo post type mới bằng hàm register_post_type của WordPress và bạn chỉ muốn nhóm người dùng admin quản lý được các bài viết trong post type này thì bạn làm như sau:
function hocwp_book_setup_post_type() { $args = array( 'public' => true, 'label' => __( 'Books', 'textdomain' ), 'menu_icon' => 'dashicons-book', 'capabilities' => array( 'edit_post' => 'update_core', 'read_post' => 'update_core', 'delete_post' => 'update_core', 'edit_posts' => 'update_core', 'edit_others_posts' => 'update_core', 'delete_posts' => 'update_core', 'publish_posts' => 'update_core', 'read_private_posts' => 'update_core' ) ); register_post_type( 'book', $args ); } add_action( 'init', 'hocwp_book_setup_post_type' );
Ngoài ra, bạn cũng có thể tùy chỉnh capability update_core thành các loại khác như: manage_options, activate_plugins,…
DDown giản dễ hiểu và đã làm thành công. Cảm ơn bác nhiều nhé.