[wp-trac] [WordPress Trac] #45539: Block Editor for CPT
WordPress Trac
noreply at wordpress.org
Sat Dec 8 16:19:37 UTC 2018
#45539: Block Editor for CPT
-------------------------------------+-------------------------------------
Reporter: sovitranjitkar | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Editor | Version: 5.0
Severity: normal | Resolution:
Keywords: needs-testing reporter- | Focuses: javascript,
feedback | administration
-------------------------------------+-------------------------------------
Comment (by sovitranjitkar):
Hello @swissspidy Below are the code that I am using to register the post
type if you found any mistakes you can also try registering a post type
with your own way with post name `themes` seems like there is an issue
with the name `themes` and you can easily see 2 errors while debugging
with developer tools from the browser.
If you change the name to any other you can able to see the `Feature
Image` section on both CPT and core Post but for the `register_taxonomy`
on CPT there is no way to show it.
{{{#!php
<?php
add_action( 'init', 'wptheme_store_themes_taxonomy');
/**
* creates a custom taxonomy for custom post type themes post
* @uses register_taxonomy
* @uses init hook
*/
function wptheme_store_themes_taxonomy() {
register_taxonomy(
'themes_categories', 'themes',
array(
'hierarchical' => true,
'label' => 'Themes store',
'query_var' => true,
'rewrite' => array(
'slug' =>
'themes/category',
'with_front' => false
)
)
);
}
/****************************************************************************************/
add_action( 'init', 'wptheme_store_register_custom_post_types' );
/**
* Registering Custom Post Type Themes
*/
function wptheme_store_register_custom_post_types() {
$labels = array(
'name' => _x( 'Themes',
'wptheme_store_custom_post','wptheme_store' ),
'singular_name' => _x( 'Theme',
'wptheme_store_custom_post', 'wptheme_store' ),
'add_new' => _x( 'Add New',
'wptheme_store_custom_post', 'wptheme_store' ),
'add_new_item' => _x( 'Add New
ThemePost', 'wptheme_store_custom_post', 'wptheme_store' ),
'edit_item' => _x( 'Edit
ThemePost', 'wptheme_store_custom_post', 'wptheme_store' ),
'new_item' => _x( 'New
ThemePost', 'wptheme_store_custom_post', 'wptheme_store' ),
'view_item' => _x( 'View
ThemePost', 'wptheme_store_custom_post', 'wptheme_store' ),
'search_items' => _x( 'Search
ThemePosts', 'wptheme_store_custom_post', 'wptheme_store' ),
'not_found' => _x( 'No
ThemePosts found', 'wptheme_store_custom_post', 'wptheme_store' ),
'not_found_in_trash' => _x( 'No ThemePosts found in
Trash', 'wptheme_store_custom_post', 'wptheme_store' ),
'parent_item_colon' => _x( 'Parent
ThemePost:', 'wptheme_store_custom_post', 'wptheme_store' ),
'menu_name' => _x( 'Themes
Posts', 'wptheme_store_custom_post', 'wptheme_store' )
);
$args = array(
'labels' => $labels,
'hierarchical' => false,
'description' => 'Custom Theme Posts',
'supports' => array( 'title',
'editor', 'excerpt', 'author', 'thumbnail', 'comments', 'revisions',
'post-formats', 'custom-fields' ),
'taxonomies' => array(
'post_tag','themes_categories'),
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => 5,
'show_in_nav_menus' => true,
'publicly_queryable' => true,
'exclude_from_search' => false,
'query_var' => true,
'can_export' => true,
'rewrite' => array('slug' =>
'themes','with_front' => FALSE),
'public' => true,
'has_archive' => 'themes',
'capability_type' => 'post',
'show_in_rest' => true
);
register_post_type( 'themes', $args );
}
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/45539#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list