admin管理员组文章数量:1130349
I have been trying to find a way to disable the Add New button in my custom post type that I have generated using CPT UI plugin. I have tried this solution - How can I remove the "Add New" button in my custom post type? but no luck.
I know there is a way to do it in register_post_type function, however, my post type was already created using the plugin and have some data saved already. If I use the function, I will have to create all the contents all over again.
Please help
I have been trying to find a way to disable the Add New button in my custom post type that I have generated using CPT UI plugin. I have tried this solution - How can I remove the "Add New" button in my custom post type? but no luck.
I know there is a way to do it in register_post_type function, however, my post type was already created using the plugin and have some data saved already. If I use the function, I will have to create all the contents all over again.
Please help
Share Improve this question asked Nov 16, 2018 at 15:29 aj noguerraaj noguerra 1 2- 1 Changing a post type setting isn't going to delete your content. – Milo Commented Nov 16, 2018 at 16:28
- you could always just hide it with CSS. – RiddleMeThis Commented Nov 16, 2018 at 18:08
1 Answer
Reset to default 0Thanks Milo. Didn't consider adding the register_post_type in my functions before because I thought it would interfere with the existing custom post type I made in CPT UI, turns out that it is useful and it override the CPT UI post type.
I used the same slug and it automatically connected the data to the manually created post type. Here's the code:
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/testdrive/wp-content/uploads/2018/04/logo-white-e1524992076968.png',
));
}
add_action( 'init', 'create_post_type' );
I have been trying to find a way to disable the Add New button in my custom post type that I have generated using CPT UI plugin. I have tried this solution - How can I remove the "Add New" button in my custom post type? but no luck.
I know there is a way to do it in register_post_type function, however, my post type was already created using the plugin and have some data saved already. If I use the function, I will have to create all the contents all over again.
Please help
I have been trying to find a way to disable the Add New button in my custom post type that I have generated using CPT UI plugin. I have tried this solution - How can I remove the "Add New" button in my custom post type? but no luck.
I know there is a way to do it in register_post_type function, however, my post type was already created using the plugin and have some data saved already. If I use the function, I will have to create all the contents all over again.
Please help
Share Improve this question asked Nov 16, 2018 at 15:29 aj noguerraaj noguerra 1 2- 1 Changing a post type setting isn't going to delete your content. – Milo Commented Nov 16, 2018 at 16:28
- you could always just hide it with CSS. – RiddleMeThis Commented Nov 16, 2018 at 18:08
1 Answer
Reset to default 0Thanks Milo. Didn't consider adding the register_post_type in my functions before because I thought it would interfere with the existing custom post type I made in CPT UI, turns out that it is useful and it override the CPT UI post type.
I used the same slug and it automatically connected the data to the manually created post type. Here's the code:
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/testdrive/wp-content/uploads/2018/04/logo-white-e1524992076968.png',
));
}
add_action( 'init', 'create_post_type' );
本文标签: pluginsDisable 39Add New39 in custom post that is made from CPT UI
版权声明:本文标题:plugins - Disable 'Add New' in custom post that is made from CPT UI 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749173638a2327435.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论