谢谢Milo. 之前没有考虑在我的函数中添加register\\u post\\u类型,因为我认为它会干扰我在CPT UI中创建的现有自定义post类型,结果证明它很有用,并且会覆盖CPT UI post类型。
我使用了相同的slug,它自动将数据连接到手动创建的post类型。代码如下:
function create_post_type() {
register_post_type( \'office_post\', array(
\'capability_type\' => \'post\',
\'capabilities\' => array(
\'create_posts\' => false, // Removes support for the "Add New" function ( use \'do_not_allow\' instead of false for multisite set ups )
),
\'labels\' => array(
\'name\' => __( \'Office\' ),
\'singular_name\' => __( \'Office\' )
),
\'map_meta_cap\' => true, // Set to `false`, if users are not allowed to edit/delete existing posts
\'public\' => true,
\'menu_icon\' => \'http://architecture.com/testdrive/wp-content/uploads/2018/04/logo-white-e1524992076968.png\',
));
}
add_action( \'init\', \'create_post_type\' );