Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save cdmz/0c4981a61f6482829bbf to your computer and use it in GitHub Desktop.
Save cdmz/0c4981a61f6482829bbf to your computer and use it in GitHub Desktop.
hide button add new post in submenu and list post type and page edit post
<?php
//hide button add new in submenu and list post types and edit posts
function disable_new_posts() {
// remove submenu
global $submenu;
unset($submenu['edit.php?post_type=sms-call'][10]);
unset($submenu['edit.php?post_type=sms-ajudar'][10]);
// hide button add new
if (
(
isset($_GET['post_type']) &&
(
$_GET['post_type'] == 'sms-call' OR
$_GET['post_type'] == 'sms-ajudar'
)
)
OR
(
isset($_GET['action']) AND $_GET['action'] == 'edit'
AND
(
//hide button add new in page edit post
//examples http://localhost/worpress/wp-admin/post.php?post=253
$_GET['post'] == '253' OR
$_GET['post'] == '195'
)
)
){
echo '<style type="text/css">
#favorite-actions, .add-new-h2, .tablenav { display:none; }
</style>';
}
}
add_action('admin_menu', 'disable_new_posts');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment