the plugin Site Kit by Google plays with the capabilities to do that. you can see that in the source code here.
this works actually with WordPress 6.8.1 but it’s not sure this trick will work with next versions.
to use the same trick in your code, you have to change the 2 parameters with comment in this code :
add_action('admin_menu', 'top_level_menu', 50);
function top_level_menu()
{
$menu_slug = 'wpdocs-orders-slug';
add_menu_page(
'WP Docs Orders'
, 'WP Docs Orders'
, 'do_not_allow' // this hides the first sub menu
, $menu_slug
, false
);
add_submenu_page(
$menu_slug
, 'Existing WP Docs Orders'
, 'Existing WP Docs Orders'
, 'read'
, "wpdocs_orders_function" // use a different slug than the parent
, 'wpdocs_orders_function'
);
}
Related Posts:
- add_menu_page() with different name for first submenu item
- How to avoid creating first submenu page that is same as menu page?
- Is there documentation reference for forms in menu and setting pages?
- Add a page in admin without adding menu item
- Add Admin menus or submenus depending on conditions
- Creating a table in the admin-style?
- body_class hook for admin pages
- Plugin – create a page without it appearing in the side menu
- Change admin language based on user (in single-site)
- What is the real intention for admin-post.php?
- Admin config screen without menu
- Make Categories and Tags required in admin
- How to add HTML / Form to an Admin Bar Menu
- Error with Custom Admin Screen in iframe Thickbox
- why don’t I get error messages in admin when developing?
- WP_Error handles errors, but how can I show success with a message?
- How to add more than 1 user role to sub-menu pages
- Odd behaviour with submenu link creation
- add_menu_page() with function inside a class [duplicate]
- JS / JQuery form validation in backend admin menus
- How to put placeholder text in the main post input area?
- Is it possible to modify the media library admin screen?
- What does $_registered_pages do?
- Get user id for delete and update selected user
- Add tab to profile.php wordpress plugin development
- WordPress Ajax callback function from plugin – OOP
- Hiding Admin Page While Keeping Menu Expanded
- Admin auto-refresh is interfering with Firebug — how to prevent it?
- Including a JS source with an admin page
- WordPress not working on localhost
- maintaing consistent layout wordpress dashboard
- Add column and post filter for a custom post type field on the edit.php page
- Is there no admin ui guide for 4.x?
- Sub Menu content is being duplicated
- Correct check for any admin page with editor
- Adding (blog-specific) links to “My Sites” admin page
- Change the look and feel of admin pages
- Admin Plugin POST to another file within the plugin
- Set different custom menu items for different user roles
- Admin – Handle data before creating or updating a post, page or custom post
- How can I replace content in the WP Admin area before an admin page is rendered?
- Including comments meta box on a plugin page
- How to Move the Comments Bubble to the Right Side of the Toolbar
- Does admin_print_scripts-$hook_suffix work for nested paths to individual files?
- How is a widget supposed to reference what is added to custom submenu or addmenu fields?
- Use ‘get’ form action within a WordPress plugin admin page
- Issue on Setting $icon_url Parameter on WP add_menu_page()
- Does is_admin() really provide a plugin performance improvement?
- Disable Auto-Expanding Menu in WordPress Admin Menus
- Best practice for plugin: always detect admin-ajax call?
- Adding submenu to custom plugin menu page created with add_menu_page() function
- Plugin Development – Get Admin Url (Including cases where wp-admin is not used)
- Proper way to create an administration page without adding it to the menu
- using admin functions on frontend
- How to Call Specific .PHP file on add_submenu_page selection in Plugin Development?
- Why won’t this submenu page show? – My First WordPress Plugin
- How to create a custom post-new.php page for plugin , no wp menu
- How to add styles to a submenu page?
- Google Web Core Vitals – management, how to in wordpress and advice
- Add two button to page and post admin to redirect to : add new & list of (posts – pages) just after saving post or page
- Add a custom submenu under submenu in a Custom WordPress Plugin
- How to create plugin settings page for each admin user?
- How to return a blank page
- Adding admin for specific users
- How do I control the list of Pages an author can see?
- What happens when you create/edit a menu
- edit-tags.php in plugin admin menu hides when is the active page
- Adding querystring variable breaks admin URLs
- loop and in admin header problem
- modify buddpress adminbar only in admin pages
- Is it possible to add Custom Dashboard Widgets to Custom Admin Menu Page?
- Custom database table entry edit page
- Is there a way to decide from init whether we are on a certain backend page?
- Checking if a file is already in the Media Library
- How can I track active users of my plugin? and why doesn’t WordPress.Org offer this?
- What’s the Right Way to get and save remote data for a Gutenberg block?
- Passing array of strings to a SQL statement in a WordPress plugin
- Add multiple shipping rates from add_rate function with custom ID
- Admin Dashboard with Custom Tab for Client
- Filter, or any way to dynamically change theme screenshot image?
- On Plugin Activation, How Do I Check for Proper Transport Mechanism?
- How to render a time-of-day string like ’16:42′ with a site’s chosen time format?
- Are block templates incompatible with serialize_blocks?
- Check Paypal Purchase is Success or Not in Easy Digital Download Plugin
- Render content after post title in wp-admin
- Notice: Trying to get property ‘term_id’ of non-object
- How to change the column label in screen options for a custom column?
- include php file if page_id matches
- WordPress publish_post hook not getting featured image and meta on first publish, but works on updating title
- How to add custom view links to wp-admin/post.php?
- Get post thumbnail in WP_Query
- wp_schedule_event not executing function call, even with add_action
- How to query a nested field in wordpress api using _fields param
- function add custom fields to media gallery
- using wordpress acf shortcods in tables goes outside the table
- How to load css file after a certain css file
- Deactivate Other Incompatible Plugin Upon Activation
- Can’t get query string in ajax call
- WP Cron registers hook without any action (does not call the function)
- Woocommerce Payment Plugin with Mycred being the payment processor