Skip to content

Instantly share code, notes, and snippets.

@denishvachhani
Last active December 18, 2015 08:48
Show Gist options
  • Save denishvachhani/5756491 to your computer and use it in GitHub Desktop.
Save denishvachhani/5756491 to your computer and use it in GitHub Desktop.
Remove “Add New” link from custom post type
<?php
function remove_submenus() {
if(!current_user_can('activate_plugins')) {
global $submenu;
unset($submenu['edit.php?post_type=your_custom_post-type'][10]); // Removes 'Add New'.
}
}
add_action('admin_menu', 'remove_submenus');
function hide_that_stuff() {
if('your_custom_post-type' == get_post_type())
echo '<style type="text/css">
#favorite-actions {display:none;}
.add-new-h2{display:none;}
.tablenav{display:none;}
</style>';
}
add_action('admin_head', 'hide_that_stuff');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment