Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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 ?

share|improve this question
    
    
thanks, looked at the plugin, didn't think about the simple JS option :-) –  hannit cohen Mar 8 '12 at 18:56

2 Answers 2

up vote 2 down vote accepted

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
share|improve this answer
    
I just needed the links removed, thanks. –  hannit cohen Mar 8 '12 at 18:56
    
@hannitcohen Would you mind accepting the answer if it helped? –  kaiser Mar 8 '12 at 19:09

There is a meta capability create_posts that is not documented but is used by WordPress to check before inserting the various 'Add New' buttons and links. In your custom post type declaration, add capabilities (not to be confused with cap) and then set it to false as below.

register_post_type( 'custom_post_type_name', array(
  'capabilities' => array(
    'create_posts' => false,
  )
));
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.