This usually happens when you are trying to do admin navigation stuff and you aren’t hooked into admin_menu
. If you hook in before that, $menu
hasn’t been created yet.
add_action('admin_menu', 'my_plugin_add_menu');
function my_plugin_add_menu(){
$ptype="my_post_type";
$ptype_obj = get_post_type_object( $ptype );
add_submenu_page( 'my-menu-item', $ptype_obj->labels->name, $ptype_obj->labels->all_items, $ptype_obj->cap->edit_posts, "edit.php?post_type=$ptype" );
}
Related Posts:
- Add separator to admin submenu
- How can I get an array/list of all current WordPress Admin Menu items?
- how to only add a top-level admin menu without it creating a sub-level-menu
- Hiding Admin Page While Keeping Menu Expanded
- What’s causing this error? “Warning: Invalid argument”
- wp_is_mobile() inside js
- Appearance > Menus
- Is It Possible To A Link To The Homepage From The Admin Sidebar?
- Changing the Order of Admin Menu Sections?
- Adding an Arbitrary Link to the Admin Menu?
- Placing a Custom Post Type Menu Above the Posts Menu Using menu_position?
- Error: Declaration of MyClass::start_lvl() should be compatible with that of Walker_Nav_Menu::start_lvl()
- Error “Trying to get property of non-object” with Custom Walker for wp_nav_menu
- Renaming a WordPress Admin Menu
- Remove Pagination in Appearance -> Menus -> Categories
- renaming an admin menu item with decimal array index number
- How to add menu to Dashboard that can be viewed by all users
- How to fix strange 500 Error after Editing Menu?
- Add column to pages table
- Make Theme automatically choose default nav menu
- Move admin menu at the end
- Is it possible to add a filter for the output of nav-menu items in admin?
- How to make pages metabox display all hierarchy in menu admin?
- Hide pages depending on role
- How to display custom post meta in the appearance->menus page
- Getting stripos error when trying to add menu classes
- Error “The given object ID is not that of a menu item” on menu with 40+ items
- Remove Metabox from Menus screen
- Sort wp_nav_menu() by menu order
- Theme menu in Admin Panel
- Custom Admin Menu Order
- Disabling ‘posts’ in Appearance > Menus
- Wp menu add page link as custom empty link
- Get admin menu link
- Missing Menus Structure
- Hook for number of items in Appearance > Menus > CustomPostType > View All [duplicate]
- Filter for Admin Nav Menus Drop Down
- SlideDeck 2, make back-end visible for admins only
- Limit the menu child levels under “admin > appearance > menus”
- Change name & menu_name for Profile in the default menu, w/o altering core files?
- Add column to pages table
- WordPress menu not loading in the admin side appearence-> menu tab
- Programmatically add existing pages and subpages to Appearance Menu
- Cant add menu items with my theme
- WordPress Plugin menu position overwrite other item
- Ad custom admin page like WordPress customizer [closed]
- Admin menu structure
- How to remove menu installed in wp-admin by a theme? [closed]
- Appearance Menus Screen – menu item drop down menu not functioning
- Adding an admin menu page showing the link twice – how to solve this?
- Why am I timing out when using the Menu Editor?
- Admin-ajax.php 500 error when Add to menu is clicked in admin
- Can I have custom post types in “Add menu items” on in the Admin > Appearance > Menu
- Add Labels to Admin Menu ( How To )
- How can I make a menu link visible only to admins (without plugins)?
- How can I add a menu item to the admin area?
- Admin top level menu, pointing to an external url
- Adding top level items in the admin menu that link to a post
- enqueue script during add menu items means before save menu items
- How to get submenu of admin menu?
- Strange menu behaviour wordpress admin [duplicate]
- Adding CSS-class to WordPress Menu in backend
- Menu deletes all items and position – wordpress bug?
- Plugins & Setting Menu Items Removed From Admin Panel
- add_menu_page does not render the expected result
- Admin Menu Hack (Left side in Dashboard)
- Lost admin “manage_link” capability WordPress. No “Links” menu item in admin menu
- WordPress menu items automatically becoming empty custom links
- Admin menu in different languages
- Need to remove the admin menu item from a be theme in wordpress
- Add category label for appearance > menus items
- Removing wp admin menu item on top bar of admin backend
- Error: Declaration of MyClass::start_lvl() should be compatible with that of Walker_Nav_Menu::start_lvl()
- Restrict user to edit only edit a certain menu
- Need Help Regarding Menu Magement in admin
- Roles see different top menu (nav menu)
- how to create pages and link them to a menu
- Dashicons not showed for admin menu
- Links in new menu don’t work
- Error: Declaration of MyClass::start_lvl() should be compatible with that of Walker_Nav_Menu::start_lvl()
- How to create menu in Word Press 4.2.2?
- Removing menu item doesn’t get removed on edit post
- Customizing label/title output of admin nav_menu selecter
- Query for menus in backend (BE)
- List of WordPress menu item indices?
- How do I fix the URL used in the WordPress admin menu for customize.php
- How can I disable sorting/dragging of a menu item in the custom menu admin?
- Custom menu linking to page not found
- How to let the role “editor” to control the menu?
- How to change the markup created by menu item only on chosen items?
- How to change WP menu item type?
- Critical Error when editing menu
- Is it OK to move admin menu items?
- replace current_page_item class in menu
- Adding attributes to link in wp_nav_menu using custom Walker function
- WordPress – site with 2 stylesheets and more…
- Why is only the first operation run in my loop – except for on the last repeat? [closed]
- Putting footer links into different columns
- Display searchform in the menu
- How to add a toggle on the left side of my page?