How to Add Custom Menu Items to the WordPress Dashboard Sidebar
How to Add Custom Menu Items to the WordPress Dashboard Sidebar
The WordPress dashboard sidebar provides quick access to various sections of your site, such as posts, pages, and settings. However, if you want to add custom menu items to improve workflow or provide quick access to specific pages, you can do so with a simple code snippet.
In this guide, we’ll show you how to add custom menu items to the WordPress admin dashboard sidebar.
Why Add Custom Menu Items?
Adding custom menu items can help:
- Provide quick access to frequently used pages.
- Link to external resources or tools.
- Improve workflow by organizing custom plugin settings or pages.
Code Snippet: Adding a Custom Menu Item
To add a custom menu item, insert the following code into your theme’s functions.php
file or a custom plugin:
Explanation
add_menu_page()
: Creates a new top-level menu item.- Page Title: The title displayed on the page.
- Menu Title: The title displayed in the dashboard menu.
- Capability: Determines which users can access the menu item (
manage_options
is for administrators). - Menu Slug: The unique identifier for the menu.
- Callback Function: The function that renders the page.
- Icon: Dashicon class for the menu item.
- Position: Determines where the menu item appears in the sidebar.
Adding a Submenu Item
To add a submenu under an existing menu item, such as Settings, use this snippet:
Final Word
Adding custom menu items to the WordPress admin sidebar allows you to create quick-access links for your team or yourself, enhancing workflow and usability. Whether linking to external tools, custom plugin settings, or frequently used pages, this simple customization can improve your WordPress experience.