Randy Hoyt

Rearranging the WordPress Admin Menu

The WordPress admin menu puts Posts as the first content type, which makes sense when you consider that most of the sites it powers are blogs. Many of the sites I build in WordPress, however, are content sites that either have no blog or have one of only secondary importance. I will typically add this small bit of code to a custom plugin or to my theme’s function file to move Pages to the top of the list:

add_action('admin_menu', 'rrh_change_post_links');
function rrh_change_post_links() {
	global $menu;
	$menu[6] = $menu[5];
	$menu[5] = $menu[20];

Let me explain how this works. The $menu variable is an array of items. The array has some gaps where new items could be placed. By default Posts is in array slot 5, and Pages is in array slot 20. There is nothing in array slot 6. My functions moves Posts from 5 to 6, moves Pages from 20 to 5, and then removes 20.

You can modify any elements in the array. When you add custom post types, they will also appear in the array … and you can move them around just like the core elements.