8

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 Answers 2

11

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?

6
  • 1
    Of course, athletes is the name of my Custom Post Type... Adjust as necessary.
    – brasofilo
    Jul 5, 2012 at 0:59
  • It works! cool! Thanks for showing how I could've searched!
    – Alisso
    Jul 5, 2012 at 1:16
  • Can I choose two right answers?
    – Alisso
    Jul 5, 2012 at 1:16
  • @Alisso No. You can only choose one. Since both show the same solution in part, you might want to choose one has the all (or most) the necessary details you need. :)
    – its_me
    Jul 5, 2012 at 4:14
  • 1
    This function doesn't remove anything, it merely hides it.
    – user2015
    Oct 15, 2015 at 3:49
2

I just tried and remove_menu_page('edit.php'); only removes the Posts Top Level Menu.

All my other custom post types (and I have a lot) still work fine. I have a feeling this is because it does a direct lookup of the exactly slug, not the basename of the file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.