Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Some test data. Throw the CPT registration in functions.php
{
"name": "books",
"relationship": {
"type": "post",
"post_type": "book"
},
"columns": [
{
"name": "author",
"acf_field_name": "author"
},
{
"name": "year",
"acf_field_name": "year"
},
{
"name": "type",
"acf_field_name": "type"
}
]
}
/**
* Register Custom Post Type: Book
*/
add_action( 'init', 'register_book_cpt', 0 );
function register_book_cpt() {
register_post_type( 'book', array(
'label' => __( 'Book', 'test-theme' ),
'labels' => array(
'name' => _x( 'Books', 'Book General Name', 'test-theme' ),
'singular_name' => _x( 'Book', 'Book Singular Name', 'test-theme' ),
'menu_name' => __( 'Books', 'test-theme' ),
'name_admin_bar' => __( 'Book', 'test-theme' ),
'archives' => __( 'Book Archives', 'test-theme' ),
'parent_item_colon' => __( 'Parent Book:', 'test-theme' ),
'all_items' => __( 'All Books', 'test-theme' ),
'add_new_item' => __( 'Add New Book', 'test-theme' ),
'add_new' => __( 'Add New', 'test-theme' ),
'new_item' => __( 'New Book', 'test-theme' ),
'edit_item' => __( 'Edit Book', 'test-theme' ),
'update_item' => __( 'Update Book', 'test-theme' ),
'view_item' => __( 'View Book', 'test-theme' ),
'search_items' => __( 'Search Book', 'test-theme' ),
'not_found' => __( 'Not found', 'test-theme' ),
'not_found_in_trash' => __( 'Not found in Trash', 'test-theme' ),
'featured_image' => __( 'Featured Image', 'test-theme' ),
'set_featured_image' => __( 'Set featured image', 'test-theme' ),
'remove_featured_image' => __( 'Remove featured image', 'test-theme' ),
'use_featured_image' => __( 'Use as featured image', 'test-theme' ),
'insert_into_item' => __( 'INSERT INTO item', 'test-theme' ),
'uploaded_to_this_item' => __( 'Uploaded to this item', 'test-theme' ),
'items_list' => __( 'Books list', 'test-theme' ),
'items_list_navigation' => __( 'Books list navigation', 'test-theme' ),
'filter_items_list' => __( 'Filter items list', 'test-theme' ),
),
'description' => __( 'Book Description', 'test-theme' ),
'public' => false,
'hierarchical' => false,
'exclude_from_search' => false,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true, // true, false, or parent menu slug e.g; edit.php
'show_in_nav_menus' => true,
'show_in_admin_bar' => true,
'show_in_rest' => false,
'rest_base' => 'book',
'rest_controller_class' => 'WP_REST_Posts_Controller',
'menu_position' => 5,
'menu_icon' => '',
'capability_type' => 'page',
//'capabilities' => [], // @see get_post_type_capabilities()
//'map_meta_cap' => false,
'supports' => array(
'title',
'editor',
'comments',
'revisions',
'trackbacks',
'author',
'excerpt',
'page-attributes',
'thumbnail',
'custom-fields',
'post-formats'
),
'register_meta_box_cb' => null,
'taxonomies' => array( 'category', 'post_tag' ),
'has_archive' => true,
'rewrite' => [
'slug' => 'book',
'with_front' => true,
'feeds' => false,
'pages' => false,
'ep_mask' => EP_PERMALINK,
],
'query_var' => 'book',
'can_export' => true,
'delete_with_user' => false,
) );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.