Created
May 3, 2023 05:44
-
-
Save pierre-dekode/c934284b88ebf0a31f4e433f265c4a64 to your computer and use it in GitHub Desktop.
Steps to recreate https://core.trac.wordpress.org/ticket/57300
This file contains hidden or 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
<?php | |
declare( strict_types=1 ); | |
function wporg_register_my_custom_post_type() : void { | |
register_post_type( 'my_custom_post_type', [ | |
'label' => __( 'My Post Type', 'wporg' ), | |
'labels' => [ 'name' => _x( 'My custom post type', 'Post Type General Name', 'wporg' ) ], | |
'supports' => [ 'title', 'editor' ], | |
'hierarchical' => true, | |
'public' => true, | |
'show_ui' => true, | |
'show_in_menu' => true, | |
'menu_position' => 5, | |
'menu_icon' => 'dashicons-admin-post', | |
'show_in_admin_bar' => true, | |
'show_in_nav_menus' => true, | |
'exclude_from_search' => false, | |
'has_archive' => true, | |
'taxonomies' => [ 'my_taxonomy' ], | |
'can_export' => false, | |
'capability_type' => 'page', | |
'show_in_rest' => true, | |
] ); | |
register_taxonomy( 'my_taxonomy', [ 'post', 'my_custom_post_type' ], [ | |
'labels' => [ 'name' => _x( 'My custom taxo', 'Taxonomy Name', 'wporg' ) ], | |
'hierarchical' => true, | |
'public' => true, | |
'show_ui' => true, | |
'show_admin_column' => true, | |
'show_in_nav_menus' => true, | |
'show_tagcloud' => true, | |
'show_in_rest' => true, | |
'rewrite' => [ 'hierarchical' => true ], | |
] ); | |
} | |
add_action( 'init', 'wporg_register_my_custom_post_type', 10 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment