GeneratorsContentCustom Post Type

Custom Post Type Generator

Name it, pick what it supports, copy the register_post_type() call. Everything else stays out of your way until you ask for it.

book.php
Saved just now
Naming
Used in the database and in code. Max 20 characters, lowercase letters/numbers/dashes/underscores only.
Behaviour
Public
Visible on the front end and in the admin. Off means an internal-only type.
Hierarchical (page-like)
Allows a parent to be set. Heavy on sites with thousands of entries.
Block editor (show_in_rest)
Required for Gutenberg and the REST API.
Archive page
Generates /slug/ listing every entry of this type.
/book/
Supports
Editor panels and features this type gets.
Taxonomies
Attach at registration so query filters stay consistent.
Custom taxonomies still need their own register_taxonomy() call — the Taxonomy generator is next up.
// Generated with WP CodeKit — powered by GrowQuest (https://growquest.io).
/**
 * Register the Books post type.
 */
function mytheme_register_book_post_type() {
	$labels = array(
		'name'          => __( 'Books', 'textdomain' ),
		'singular_name' => __( 'Book', 'textdomain' ),
		'menu_name'     => __( 'Books', 'textdomain' ),
		'add_new_item'  => __( 'Add New Book', 'textdomain' ),
		'new_item'      => __( 'New Book', 'textdomain' ),
		'edit_item'     => __( 'Edit Book', 'textdomain' ),
		'view_item'     => __( 'View Book', 'textdomain' ),
		'all_items'     => __( 'All Books', 'textdomain' ),
		'search_items'  => __( 'Search Books', 'textdomain' ),
		'not_found'     => __( 'No books found.', 'textdomain' ),
	);

	$args = array(
		'labels'       => $labels,
		'public'       => true,
		'show_in_rest' => true,
		'supports'     => array( 'title', 'editor', 'thumbnail', 'excerpt' ),
		'taxonomies'   => array( 'category' ),
		'has_archive'  => true,
	);

	register_post_type( 'book', $args );
}
add_action( 'init', 'mytheme_register_book_post_type' );