Halloween Sale 15% off Ends in See the plans
PHP

Reorder the Admin Menu

Puts the admin menu items you use most at the top, in the order you choose. Everything else keeps its place below.

Don’t have WPIDE yet? Install it on your site

Code

// Menu slugs in the order you want them at the top of the menu.
$wpide_menu_order = array(
    'index.php',
    'separator1',
    'edit.php?post_type=page',
    'edit.php',
    'upload.php',
);

add_filter( 'custom_menu_order', '__return_true' );

add_filter( 'menu_order', function ( $order ) use ( $wpide_menu_order ) {
    if ( ! is_array( $order ) ) {
        return $order;
    }

    $first = array_values( array_intersect( $wpide_menu_order, $order ) );

    return array_merge( $first, array_values( array_diff( $order, $first ) ) );
} );

Notes

Find a slug by hovering a menu item: it is the part of the link after /wp-admin/.

How to add this snippet

  1. Install WPIDE on your WordPress site (it is free) and open Code Snippets.
  2. Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
  3. It is added inactive: review the code and settings, then switch it on.

Have a snippet worth sharing?

Publish it to the library from WPIDE or right here. Sign in with any WordPress site that runs WPIDE, free or Pro. Public snippets are reviewed by the WPIDE team before they appear.

Which site should get this snippet?

Enter the address of your WordPress site. WPIDE opens there in a new tab with the snippet ready to review and save.

Remembered in this browser only, so you are asked once.

Report this snippet

Tell the WPIDE team what is wrong: broken code, something harmful, spam or copied work.