The add_menu_page
function in WordPress is used to add a new top-level menu item in the admin dashboard. Here’s a breakdown of the parameters:
- Page Title: The text displayed in the browser title when the menu page is active.
- Menu Title: The text displayed on the menu item in the admin sidebar.
- Capability: The required capability to access this menu item (e.g.,
manage_options
). - Menu Slug: A unique identifier for the menu item, used in the URL.
- Function: The function that displays the content of the page.
- Icon URL: URL to the icon displayed in the menu (optional).
- Position: The position in the menu order where this item should appear (optional).
Example:
add_menu_page(
'My Page Title', // Page title
'My Menu', // Menu title
'manage_options',// Capability
'my_menu_slug', // Menu slug
'my_callback_function', // Function to display content
'', // Icon URL (optional)
6 // Position (optional)
);
This creates a new menu item in the WordPress admin with the specified properties.
Leave a Reply