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
There are several ways (depending on what you’re trying to do):
If it’s about the “publish” button
You could…
- …remove the capability from the targeted role with
remove_cap()
-
…remove the publish button 1)
1) see bottom of the answer by @toscho
-
…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…
- …simply hide the menu entry via css or js
-
…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' ); }
-
…prevent saving at all with the
per_save_post
hook and$_GET['action']
- …do a redirect when the
post-new.php
is load