Skip to content

Instantly share code, notes, and snippets.

@bacoords
Last active June 22, 2016 21:14
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 bacoords/603af17ab3c77a8dda8d to your computer and use it in GitHub Desktop.
Save bacoords/603af17ab3c77a8dda8d to your computer and use it in GitHub Desktop.
add_action( 'init', prefix_book_posttype' );
function prefix_book_posttype() {
$labels = array(
'name' => _x( 'Books', 'post type general name', 'your-plugin-textdomain' ),
'singular_name' => _x( 'Book', 'post type singular name', 'your-plugin-textdomain' ),
'menu_name' => _x( 'Books', 'admin menu', 'your-plugin-textdomain' ),
'name_admin_bar' => _x( 'Book', 'add new on admin bar', 'your-plugin-textdomain' ),
'add_new' => _x( 'Add New', 'book', 'your-plugin-textdomain' ),
'add_new_item' => __( 'Add New Book', 'your-plugin-textdomain' ),
'new_item' => __( 'New Book', 'your-plugin-textdomain' ),
'edit_item' => __( 'Edit Book', 'your-plugin-textdomain' ),
'view_item' => __( 'View Book', 'your-plugin-textdomain' ),
'all_items' => __( 'All Books', 'your-plugin-textdomain' ),
'search_items' => __( 'Search Books', 'your-plugin-textdomain' ),
'parent_item_colon' => __( 'Parent Books:', 'your-plugin-textdomain' ),
'not_found' => __( 'No books found.', 'your-plugin-textdomain' ),
'not_found_in_trash' => __( 'No books found in Trash.', 'your-plugin-textdomain' )
);
$args = array(
'labels' => $labels,
'description' => __( 'Description.', 'your-plugin-textdomain' ),
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments' ),
'public' => true,
'publicly_queryable' => true,
'has_archive' => true,
'rewrite' => array( 'slug' => 'book' ),
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => null,
'menu_icon' => 'dashicons-groups',
'show_in_rest' => true,
'rest_base' => 'books',
'rest_controller_class' => 'WP_REST_Posts_Controller'
);
register_post_type( 'prefix_book', $args );
}
//Link: http://codex.wordpress.org/Function_Reference/register_post_type
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment