Created
March 18, 2024 04:05
-
-
Save carolinan/c31ea827c5d38b1041b7b45355b2c4ca to your computer and use it in GitHub Desktop.
Block post type
This file contains 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 | |
/** | |
* @package block reference | |
*/ | |
/** | |
* Register the custom post type | |
* @since 2.0.0 | |
*/ | |
function block_reference_register_block_post_type() { | |
$labels = array( | |
'name' => _x( 'Blocks', 'Post type general name', 'block-reference' ), | |
'singular_name' => _x( 'Block', 'Post type singular name', 'block-reference' ), | |
'menu_name' => _x( 'Blocks', 'Admin Menu text', 'block-reference' ), | |
'name_admin_bar' => _x( 'Block', 'Add New on Toolbar', 'block-reference' ), | |
'edit_item' => __( 'Edit block page', 'block-reference' ), | |
'view_item' => __( 'View block page', 'block-reference' ), | |
'all_items' => __( 'All blocks', 'block-reference' ), | |
'search_items' => __( 'Search blocks', 'block-reference' ), | |
'parent_item_colon' => __( 'Parent blocks:', 'block-reference' ), | |
'not_found' => __( 'No blocks found.', 'block-reference' ), | |
'not_found_in_trash' => __( 'No blocks found in Trash.', 'block-reference' ), | |
'archives' => _x( 'Block archives', 'The post type archive label used in nav menus.', 'block-reference' ), | |
'filter_items_list' => _x( 'Filter block list', 'Screen reader text for the filter links heading on the post type listing screen.', 'block-reference' ), | |
'items_list_navigation' => _x( 'Blocks list navigation', 'Screen reader text for the pagination heading on the post type listing screen.', 'block-reference' ), | |
'items_list' => _x( 'Blocks list', 'Screen reader text for the items list heading on the post type listing screen.', 'block-reference' ), | |
); | |
$args = array( | |
'labels' => $labels, | |
'description' => 'Block custom post type.', | |
'public' => true, | |
'publicly_queryable' => true, | |
'show_ui' => true, | |
'show_in_menu' => true, | |
'query_var' => true, | |
'rewrite' => array( 'slug' => 'blocks' ), | |
'capability_type' => 'post', | |
'has_archive' => true, | |
'hierarchical' => true, | |
'menu_position' => 20, | |
'supports' => array( 'title', 'editor', 'thumbnail', 'custom-fields', 'excerpt', 'revisions', 'page-attributes', 'comments' ), | |
'taxonomies' => array( 'block-category', 'block-attribute', 'block-support', 'block-keyword' ), | |
'show_in_rest' => true, | |
"template" => array( | |
array( | |
"core/pattern", | |
array( | |
"block-reference/block-information" | |
) | |
) | |
) | |
); | |
register_post_type( 'block', $args ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment