Stop users from adding new pages or posts

// Hide the "add new" submenu for a custom post type
// uses the custom function get_current_post_type()
add_action('admin_menu', 'pp_hide_YOUR_CPT_addnew_submenu');
function pp_hide_YOUR_CPT_addnew_submenu() {
 global $submenu;
 unset($submenu['edit.php?post_type=YOUR_CPT'][10]);
}

// Hide the "add new" button on a custom post type edit page
add_action('admin_head','pp_hide_YOUR_CPT_addnew_button');
function pp_hide_YOUR_CPT_addnew_button() {
 global $pagenow;
 if(is_admin()){
 if( ($pagenow == 'edit.php' && get_current_post_type() == 'YOUR_CPT') || ($pagenow == 'post.php' && get_current_post_type() == 'YOUR_CPT') ){
 echo '<style>';
 echo '.add-new-h2{';
 echo 'display: none;';
 echo '}';
 echo '</style>';
 } 
 }
}

Revisions

Tags: ,

No comments yet.

Leave a Reply