How to remove ‘create new post’ entry for a custom post type?

I have a custom post type that is created using a form on the site.
I want to disable new post creation from wordpress admin.
Is there a way to do that ?

3 Answers
3

There are several ways (depending on what you’re trying to do):

If it’s about the “publish” button

You could…

  1. …remove the capability from the targeted role with remove_cap()
  2. …remove the publish button 1)

    1) see bottom of the answer by @toscho

  3. …or the whole meta box 2)

    remove_meta_box( 'submitdiv', 'custom_post_id', 'side' );
    

    2) simplified version

If it’s about the built in `post` post type

You could…

  1. …simply hide the menu entry via css or js
  2. …unset the menu entry with

    add_action( 'admin_menu', 'myprefix_adjust_the_wp_menu', 999 );
    function myprefix_adjust_the_wp_menu() {
      $page = remove_submenu_page( 'edit.php', 'post-new.php' );
      //or for custom post type 'myposttype'.
      //$page = remove_submenu_page( 'edit.php?post_type=myposttype', 'post-new.php?post_type=myposttype' );
    }
    
  3. …prevent saving at all with the per_save_post hook and $_GET['action']

  4. …do a redirect when the post-new.php is load

Leave a Comment