// 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
- March 15, 2015 @ 13:33:02 [Current Revision] by PeterLugg
- March 15, 2015 @ 13:33:02 by PeterLugg
No comments yet.