I have removed the post menu from the admin side bar like so:
add_action('admin_menu','remove_default_post_type');
function remove_default_post_type() {
remove_menu_page('edit.php');
}
How can I now remove it from the top bar ‘new’ menu as well?
The users can still create new posts if the URL is known, like;
domain.com/wp-admin/post-new.php
Here is the code you can use for that … added it to the file
functions.php
To remove submenus you can inspect the menu you will see every
li
will have an ID similar towp-admin-bar-new-content
to remove said menu item, just removewp-admin-bar-
. With that we can look at+New -> Post
item which has an ID ofwp-admin-bar-new-post
so we can remove it like so:Reference Link / Tutorial
Try with the following code :
Thanks to Abhik
this code worked for me: