I am adding a large number of custom post types and taxonomies so it is often visually clearer if I DO NOT have them all added to the admin menu's top level. Instead I would prefer to add them under an appropriate sub-menu. I have done that without too much effort with this two step approach:
- Hiding CPT using the 'show_ui' property when registering the CPT
- Adding them back in using the add_submenu_page() call
For instance, here's an example of the the add_submenu_page call for a CPT called "companies":
By taking these two steps I can now view the CPT, I can modify existing attributes, I can even delete a record but what I can't do is add a record. When I click on the "Add New" button it comes back with a white screen that only says "Invalid post type".
Now if I simply turn on the normal top-level menu (leaving all other settings alone), I get the menu now showing up both as a submenu (from my add_submenu_page call) and as a top-level menu (because I've turned that back on with "show_ui". I can then add new items with no problem.