WordPress: Disable “Add New” on Custom Post Type

前端 未结 10 941
执笔经年
执笔经年 2020-12-07 14:58

Is there any way to disable the option of adding a new post under a Custom Post Type in WordPress (3.0)? I\'ve looked into labels and arguments but can\'t find anything that

10条回答
  •  误落风尘
    2020-12-07 15:22

    Disable creating new post for registered post-types: (example for post and page)

    function disable_create_newpost() {
        global $wp_post_types;
        $wp_post_types['post']->cap->create_posts = 'do_not_allow';
        //$wp_post_types['page']->cap->create_posts = 'do_not_allow';
        //$wp_post_types['my-post-type']->cap->create_posts = 'do_not_allow';
    }
    add_action('init','disable_create_newpost');
    

提交回复
热议问题