If I understand you, what you are doing is almost correct. You need add_menu_page
instead of add_submenu_page
add_action('admin_menu', 'register_my_custom_submenu_page');
function register_my_custom_submenu_page() {
add_menu_page( 'My Custom Submenu Page', 'My Custom Submenu Page', 'manage_options', 'my-custom-submenu-page', 'my_custom_submenu_page_callback' );
}
function my_custom_submenu_page_callback() {
echo '<h3>My Custom Submenu Page</h3>';
}
As far as the “embedded” PHP, you already have it. Everything in that code is PHP. You can add whatever other PHP you want inside that callback (my_custom_submenu_page_callback
) and it should work so long as the PHP itself is valid and you watch out for variable scope and such.
Your capability– manage_options
— may need to be changed. That depends on how you want it to work.
Related Posts:
- In the Admin Dashboard, can I choose which sections to display?
- WP admin style not refreshing
- Changing the Order of Admin Menu Sections?
- Remove unusable metaboxes in nav menu management screen
- Remove Pagination in Appearance -> Menus -> Categories
- How to add menu to Dashboard that can be viewed by all users
- Menu is invisible in admin panel but it’s visible in front-end [closed]
- Hide pages depending on role
- WP /wp-admin/admin-ajax.php produces 404
- Sort wp_nav_menu() by menu order
- Theme menu in Admin Panel
- show different admin menu to different user roles
- Navigation Menus Depth for specific menus
- Change search results order for Admin -> Appearance -> Menus -> Pages -> View all
- ‘Users’ and ‘Appearance’ have disappeared from dashboard menu [closed]
- Ad custom admin page like WordPress customizer [closed]
- How to remove menu installed in wp-admin by a theme? [closed]
- Custom Menu Broken WP 3.8.1 Update
- Use wp_logout_url() in menu creation page
- Limit User Iinterface for Admin?
- Is it possible to add a dynamic link in the main navigation in a child theme
- Rename menu items for All except super admin
- Admin top level menu, pointing to an external url
- how to remove description from menu buttons?
- In admin edit-menu screen, newly added menu items always go to the bottom of the list
- Menu page with three columns
- Additional navigation bar in header
- How to remove empty menu space when creating admin page without menu title using add_submenu_page
- Trying to add Newline in Menu item
- WordPress Dashboard add user password not working, etc
- How to work with a custom theme that someone else created before me? (details below)
- Is it possible to remove the highlighted menu on Users and highlight a different menu?
- Need Help Regarding Menu Magement in admin
- How do i make a custom top level dashboard menu item available for all users?
- how to configure this type of menu
- Menus not visible in Appearance after being registered
- How to separate sub-menu output and keep associated with parent
- wp_is_mobile() inside js
- change link of menu particular tab
- Customizing label/title output of admin nav_menu selecter
- List of WordPress menu item indices?
- How to handle change the appearance of ‘categories’ box on dashboard?
- Rename Menu icon in Twenty seventeen theme
- Critical Error when editing menu
- Is there an easy way to replace a custom menu link with a page or post?
- Add “external” link to admin menu in the backend
- Why do Custom Nav Menus generate so many classes on list items? Can I manage this somehow?
- Using nonce in menu item
- How show sub menu only using wp_nav_menu()
- List children of second level sub page
- Show top-level parent with submenu menu walker
- Adding menu items dynamically using wp_nav_menu_objects
- BuddyPress – How to add logout in nav menu
- How to remove div container in custom menu?
- Making menu link open in new tab?
- How to translate menu items?
- echo same menu items across multi-site platform
- Custom Menu url is Empty
- Menus don’t appear in admin area / WordPress Multisite
- Programmatically add existing pages and subpages to Appearance Menu
- wp_nav_menu() doesn’t work
- Insert other menus as submenus of a main menu
- Make a navigation menu in the same post [duplicate]
- Count within foreach loop
- changing host.. data loss
- How to buid wordpress menu with auto width sub-menu items in dropdown menu without any items sharing one line [closed]
- How to avoid a duplicate query from using wp_nav_menu?
- Wrapping menu’s top-level link and sub-menus in div
- Dashboard : remove Safari navigator message
- Menu on mobile version doesn’t collapse after choosing menu item [closed]
- Parent Page > Child Page Menu
- Opening Menu link in another tab
- Page header menu links change
- Trying to create a page as a menu item in the admin while keeping the admen panel visible
- How do I add 3rd level of dropdowns to wp_nav_menu array?
- insert div into a menu item before the link and more
- Multisite Setup – Menu Items To Reference Pages in Different Subdomains
- changin the url (permalink as it goes these days) on one specific menu layer
- Admin: WooCommerce Navigation Menus do not show empty categories search tab
- Using Anchor Link In Nav Menu
- WordPress database issues – menu not saving correctly, media thumbnails not showing
- How do I create a new directory to hold the assets for a new menu item?
- How to set active class to the menu of any page coming from a single.php template
- Sum root term’s entries count from child terms count
- Add newsletter signup element to navigation bar
- All custom links suddenly lack href attributes
- WordPress – Apperance > Menu
- how to keep theme background image, menu or site header image while moving site in sub directory?
- Show posts of parent in edit.php
- Unable to edit Navigation bar
- Editor user only allow to post on certain categories
- Menu Underline shows without Hover after adding subitems
- Add class to current category menu item
- Should I custom code drop down menus or use a wordpress plugin?
- How to load css file in my menu in wordpress
- Navigation menu, remove item from desktop
- Jquery dropdown menus working locally, but not in WordPress [duplicate]
- Wrapping my ‘s with
- Add acf custom fields so sub item in menus
- change breakpoint widths for divi theme tablet view