Created
September 9, 2014 21:45
-
-
Save yellowberri-snippets/40b1e74f4a27060d009e to your computer and use it in GitHub Desktop.
PHP: WP: Custom Post Type Definition
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function cpt_book_init() { | |
$labels = array( | |
'name' => 'Books', | |
'singular_name' => 'Book', | |
'menu_name' => 'Books', | |
'name_admin_bar' => 'Book', | |
'add_new' => 'Add New', 'book', | |
'add_new_item' => 'Add New Book', | |
'new_item' => 'New Book', | |
'edit_item' => 'Edit Book', | |
'view_item' => 'View Book', | |
'all_items' => 'All Books', | |
'search_items' => 'Search Books', | |
'parent_item_colon' => 'Parent Books:', | |
'not_found' => 'No books found.', | |
'not_found_in_trash' => 'No books found in Trash.', | |
); | |
$args = array( | |
'labels' => $labels, | |
'public' => true, | |
'publicly_queryable' => true, | |
'show_ui' => true, | |
'show_in_menu' => true, | |
'query_var' => true, | |
'rewrite' => array( 'slug' => 'book' ), | |
'capability_type' => 'post', | |
'has_archive' => true, | |
'hierarchical' => false, | |
'menu_position' => null, | |
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments' ) | |
); | |
register_post_type( 'book', $args ); | |
} | |
add_action( 'init', 'cpt_book_init' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment