在wp-admin中,我创建了一个新的管理菜单页面。Wordpress设置自定义文章类型的特色图像
add_menu_page('My custom post page type title', 'My custom post type menu', '', 'my-custom-slug', '', '', 99);
add_submenu_page('my-custom-slug', 'Add new', 'Add new', 'manage_options', 'post-new.php?post_type=my-custom-post-type', '');
我想使用像post-new.php和edit.php这样的面板,所以我注册了一个自定义的帖子类型。
register_post_type('my-custom-post-type',
array('labels'=>array('name'=>__('Products','text-domain'),
'singular_name'=>__('Product','text-domain'),
'menu_name'=>_x('Products','Admin menu name','text-domain'),
'add_new'=>__('Add Product','text-domain'),
'add_new_item'=>__('Add New Product','text-domain'),
'edit_item'=>__('Edit Product','text-domain'),
'new_item'=>__('New Product','text-domain'),
'view_item'=>__('View Product','text-domain'),
'not_found'=>__('No Products found','text-domain'),
'not_found_in_trash'=>__('No Products found in trash','text-domain')),
'supports'=>array('title','editor','thumbnail','comments')
'rewrite'=>array('slug'=>'mscases'),
'public'=>true,
'capability_type'=>'post'));
自定义菜单页能正常工作,而元框Featured Image
也工作得很好,我可以选择图像中的媒体库。
当我选择图片后,它不会出现在精选图片元框中,并且admin-ajax.php
响应是-1(我检查帖子页面,如果成功,则为零)。
但是,如果我将参数my-custom-post-type
更改为product
(如woocommerce),则会显示我选取的精选图像。
有没有什么我想念编码?