Remove “posts” from admin but show a custom post

After checking out:
http://codex.wordpress.org/Function_Reference/remove_menu_page,
I successfully use the following code to hide some stuff from the menu:

add_action( 'admin_menu', 'my_remove_menu_pages' );

function my_remove_menu_pages() {
    remove_menu_page('link-manager.php');
    remove_menu_page('tools.php');
    remove_menu_page('users.php');
    remove_menu_page('edit-comments.php');  
}

However both the “posts page” and a custom post types page seems to run on /wp-admin/edit.php.

So I’m looking for a way to hide the posts menubar but still show the menu for a custom post type I’ve added.

2 s
2

Doing this search, I’ve found this fine answer by Chris_O. There’s even a jQuery solution I proposed there.

Anyway, the function remove_menu_page('edit.php'); only removes the Posts menu.

But, as we learn from Chris answer, remove_menu_page('edit.php?post_type=athletes'); removes the Custom Post Type menu.

To really block access to the URL, as we’re merely hiding the menu item, check the following Q&A: Blocking Administrative Access to Authors and Subcribers?

Leave a Comment