Skip to content
Merlin Tools

Custom Post Type generator

A full register_post_type, without writing it from memory.

Genuinely free. No sign-up, no email, no limits, no cookies. We don't store the URL you analyse.

E.g. dashicons-book, dashicons-cart…

Code
<?php
add_action( 'init', function () {
	register_post_type( 'book', array(
		'labels'       => array(
			'name'          => 'Books',
			'singular_name' => 'Book',
			'add_new_item'  => 'Add Book',
			'edit_item'     => 'Edit Book',
		),
		'public'       => true,
		'has_archive'  => true,
		'menu_icon'    => 'dashicons-book',
		'supports'     => array( 'title', 'editor', 'thumbnail', 'excerpt' ),
		'show_in_rest' => true,
		'rewrite'      => array( 'slug' => 'book' ),
	) );
} );

What it's for

Registering a Custom Post Type means remembering dozens of labels and arguments by heart. Fill four fields and get the complete function, with correct labels and Gutenberg support already on.

← All WordPress tools

Frequently asked questions

Why is show_in_rest on?

Because it's required to use the block editor (Gutenberg) and the REST API with this content type. If you only need the classic editor you can set it to false.