Skip to main content
You can add custom menu entries to the MainWP Dashboard navigation sidebar using PHP filters. This lets you create shortcuts to frequently used pages or integrate external tools.

What You’ll Learn

  • How to add custom menu items to the navigation
  • How to control menu position
  • How to customize menu icons

Prerequisites


Add a Custom Menu Entry

1

Open Custom Dashboard

Navigate to the Custom Dashboard extension settings.
2

Add the PHP code

Go to the PHP tab and add the following code:
add_filter( 'mainwp_main_menu', 'mycustom_mainwp_main_menu', 10, 1 );
function mycustom_mainwp_main_menu( $left_menu ) {
    // Position of the menu item (0 = first, 1 = second, etc.)
    $index = 2;
    $sub_menu_after = array_splice( $left_menu['leftbar'], $index );

    $addition_item = array();

    $addition_item[] = 'Updates';                    // Menu item title
    $addition_item[] = 'mainwp_tab';                 // Parent key
    $addition_item[] = 'admin.php?page=UpdatesManage'; // URL or page slug
    $addition_item[] = 'updates_custom_id';          // HTML ID attribute
    $addition_item[] = '';                           // Icon class (optional)

    // Add the item to the leftbar array
    $left_menu['leftbar'][] = $addition_item;

    // Merge arrays to maintain menu order
    $left_menu['leftbar'] = array_merge( $left_menu['leftbar'], $sub_menu_after );

    return $left_menu;
}
Custom Dashboard extension PHP tab for adding menu code
3

Customize the values

Modify the $addition_item[] values for your needs:
ValueDescriptionExample
TitleText displayed in menu'My Custom Page'
Parent keyKeep as 'mainwp_tab''mainwp_tab'
URLPage URL or admin slug'admin.php?page=MyPage'
IDHTML element ID'my_custom_id'
IconFomantic UI icon class'chart bar'
4

Change position (optional)

Modify the $index value to control where the menu item appears:
  • 0 = First position
  • 1 = Second position
  • 2 = Third position
5

Save changes

Click Save Changes. The new menu entry appears immediately.MainWP navigation sidebar showing the new Updates menu entry

Add an Icon

To add an icon, use a class from the Fomantic UI icon library:
$addition_item[] = 'chart bar';  // Adds a bar chart icon
Common icon examples:
  • 'home' - Home icon
  • 'cog' - Settings gear
  • 'chart bar' - Bar chart
  • 'user' - User icon
  • 'envelope' - Email icon

Self-Check Checklist

  • Custom Dashboard extension installed
  • PHP code added to PHP tab
  • Menu title and URL customized
  • Position index set correctly
  • Changes saved
  • New menu entry visible in navigation