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[] = 'custom_updates';             // Unique menu key
    $addition_item[] = 'admin.php?page=UpdatesManage'; // URL or page slug
    $addition_item[] = 'updates_custom_id';          // HTML ID attribute
    $addition_item[] = '<i class="sync icon"></i>';  // Icon HTML (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'
Menu keyUse a unique internal key'my_custom_page'
URLPage URL or admin slug'admin.php?page=MyPage'
IDHTML element ID'my_custom_id'
IconFomantic UI icon HTML'<i class="chart bar icon"></i>'
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, pass the full icon HTML from the Fomantic UI icon library:
$addition_item[] = '<i class="chart bar icon"></i>';  // Adds a bar chart icon
Common icon examples:
  • '<i class="home icon"></i>' - Home icon
  • '<i class="cog icon"></i>' - Settings gear
  • '<i class="chart bar icon"></i>' - Bar chart
  • '<i class="user icon"></i>' - User icon
  • '<i class="envelope icon"></i>' - Email icon
If you use only the class name, such as chart bar, MainWP renders it as plain text instead of an 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