WordPress.org

Codex

Plugin API/Filter Reference/menu order

Description

This hook adds the ability for plugins to reorder top-level menus. Attached code demonstrates menus with Dashboard, Posts, and Comments in the first menu group. The remaining menus follow in their usual order. When filtering the order array, any menus that are not mentioned in the array will be sorted after ones that are mentioned. Unmentioned menus are sorted in their usual order, relative to other unmentioned menus.

Examples

function enable_custom_menu_order() {
	return true;
}

function custom_menu_order() {
	return array( 'index.php', 'edit.php', 'edit-comments.php' );
}

add_filter( 'custom_menu_order', 'enable_custom_menu_order' );
add_filter( 'menu_order', 'custom_menu_order' );

You can use a single function if you don't need conditional filter switching:

function custom_menu_order( $menu_ord ) {
	if ( !menu_ord )
		return true;
	return array( 'index.php', 'edit.php', 'edit-comments.php' );
}
add_filter( 'custom_menu_order', 'custom_menu_order' );
add_filter( 'menu_order', 'custom_menu_order' );

Return to Plugin API/Filter Reference