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?
- Create child of child custom page in wp-admin
- TEMPLATEPATH without the theme name? No THEMEPATH constant?
- wp_update_post deletes post meta in CPT
- Update Data parameter of a wp_localize_script() call
- Admin AJAX doesn’t work in plugin admin page – Even though code is copied verbatim from WordPress Codex
- flush rewrite rules after plugin update?
- Download button in a plugin’s settings page
- Data not insert and update through ajax and jQuery in admin page?
- Full documentation about $args for register_rest_route?
- WP Plugin with Upgrade option
- Plugin settings are saving but the fields
- Bootstrap Error in WordPress plugin
- wp_enqueue_scripts in a plugin’s class
- Including content into an add_shortcode() function
- How to integrate plugins into block editor
- One-way DB Migration Workflow
- Which filter to use to pre-parse form elements, which are generated by plugin’s shortcode?
- How to Disable Content Warning Dialog for Logged in users
- How to filter get_adjacent_post()?
- Children Shortcodes?
- How to load another page file of my custom plugin file
- dbDelta not doing what it says
- Custom options page for themes
- I want to encrypt my WordPress plugin
- How can I make my website with wordpress having on-spot editing feature as compared to concrete5 CMS?
- The plugin generated 3265 characters of unexpected output
- my worrdpress admin bar shifetd into left and it force to dont work proper something. anybody know to how solve it