Custom post type and ACF generator
register_post_type code with an optional ACF field group.
Post type
Lowercase, up to 20 characters.
Taxonomy
ACF field group
functions.php or a plugin file
<?php
add_action( 'init', function () {
register_post_type( 'book', array(
'labels' => array(
'name' => __( 'Books', 'my-theme' ),
'singular_name' => __( 'Book', 'my-theme' ),
'add_new_item' => __( 'Add New Book', 'my-theme' ),
'edit_item' => __( 'Edit Book', 'my-theme' ),
'new_item' => __( 'New Book', 'my-theme' ),
'view_item' => __( 'View Book', 'my-theme' ),
'search_items' => __( 'Search Books', 'my-theme' ),
'not_found' => __( 'No books found', 'my-theme' ),
'not_found_in_trash' => __( 'No books found in Trash', 'my-theme' ),
'all_items' => __( 'All Books', 'my-theme' ),
),
'public' => true,
'has_archive' => true,
'hierarchical' => false,
'show_in_rest' => true,
'menu_icon' => 'dashicons-book',
'supports' => array( 'title', 'editor', 'thumbnail' ),
) );
} );Runs in your browser. Nothing you enter is sent anywhere.