Wordpress ordering admin menu - can't move Jetpack

Scorpion Ghost

Elite Member
Executive VIP
Jr. VIP
Joined
Mar 22, 2013
Messages
9,204
Reaction score
10,500
So I want to organize the admin dashboard items, and I figured out how to do it, but I can't move Jetpack.

I added this in functions.php

PHP:
function custom_menu_order($menu_ord) {
  if (!$menu_ord) return true;
  return array(
    'index.php',               //display dashboard
    'upload.php',              // media
    'plugins.php',             // plugins
    'edit-comments.php',       // comments
    'edit.php?post_type=page', // pages
    'edit.php',                // posts
    'edit.php?post_type=feedback', // contact form
    'wpseo_dashboard',         // yoast
    'jetpack',         // jetpack
  );
}
add_filter('custom_menu_order', 'custom_menu_order');
add_filter('menu_order', 'custom_menu_order');

This orders the items on the menu exactly like you see in the code.

Dashboard
Media
Plugins
Comments
etc

But I can't move Jetpack because the URL is different than the rest of them.

Wordpress pages are like this - /wp-admin/plugins.php
Plugins pages are like this - /wp-admin/admin.php?page=wpseo_dashboard

But Jetpack is like this - /wp-admin/admin.php?page=jetpack#/dashboard

And because of the symbol and slash there, I can't figure out how to move it. I tried different variations, but nothing works.

So I'm left with this:

nobad.PNG

Jetpack doesn't belong there. Seeing that just creates chaos in my brain. It's anarchy :D

Wordpress native pages go up, and plugins go down. This is how I like it.

Any ideas how to move that tab? @BlogPro
 
The code you've shared uses the custom_menu_order hook from WordPress and should fix the issue regardless.

The # in the URL is what is known as a fragment identifier. - https://en.wikipedia.org/wiki/URI_fragment - it denotes a particular output within an HTML, that with proper Javascript can load an entire page without reloading the page everytime the link is clicked.

It shouldn't make a difference in the way the hook is processed by WordPress.

I added the above code, as is, to my local dev environment and got this - The Jetpack list item is way down.

EoDMFut


I then moved it to the topmost area and got this.


FllrRTC


So the code works as expected, the error/conflict is happening somewhere else.
 
Well, that's most unfortunate. I cannot get it to move.

I even tried to remove it completely using this:

PHP:
function menu_shuffle() {
  remove_menu_page( 'jetpack' );
};

add_action( 'admin_menu', 'menu_shuffle' );

I figured if I can remove it from there, I can then re-add it maybe, and then maybe I can move it where I want.

But it's still there. It won't move or be removed.

I'd assume the hook is wrong and look for a different way to hook it, but you say it works for you.

Any ideas?
 
This code works to remove any of the other tabs by the way, for example:

PHP:
function menu_shuffle() {
  remove_menu_page( 'Wordfence' );
};

add_action( 'admin_menu', 'menu_shuffle' );

Works.
 
PM me the access, I'll take a look in sometime.
 
PM me the access, I'll take a look in sometime.

Okay, sent.

Really the only other idea I have is to learn how the positions of the tabs are set by default, and if each plugin determines its on position, to find where that code is located for Jetpack, and change it.

I got nothing else :D
 
After spending FAR too much time and energy on this, I figured it out, by luck.

I stumbled upon this - https://wordpress.stackexchange.com/questions/103917/removing-the-main-link-to-jetpack-from-the-menu

Guy says:

Jetpack's menu is added quite late, so you'll need to change the default priority to remove it a bit later (priority 999)

Oh fuck me!!!

So I added 999 to my code, and then Jetpack finally moved. Here is my code:

PHP:
function custom_menu_order($menu_ord) {
  if (!$menu_ord) return true;
  return array(
    
    'index.php',                   //display dashboard
    'upload.php',                  // media
    'plugins.php',                 // plugins
    'edit-comments.php',           // comments
    'edit.php?post_type=page',     // pages
    'edit.php',                    // posts
    'edit.php?post_type=feedback', // contact form
    'themes.php',                  // appearance
    'options-general.php',         // settings
    'edit.php?post_type=feedback', // contact form
    'wpseo_dashboard',             // yoast
    'nelio-content',               // nelio content
    'wpw-auto-poster-settings',    // social autoposter
    'TweetOldPost',                // revive old post
    'nxssnap',                     // snap autoposter
    'Wordfence',                   // wordfence
    'jetpack',                     // jetpack
    'users.php',               // users
    'tools.php',                     // tools
  );
}
add_filter('custom_menu_order', 'custom_menu_order', 999);
add_filter('menu_order', 'custom_menu_order', 999);

I'll just say, if I wanted to move around anything on an HTML site, it would take less than 5 minutes. No no, 5 minutes is excessive, too generous. Maybe 2 minutes, tops.

Wordpress is so unnecessarily difficult to work on sometimes.

Anyway, we're done here.
 
Back
Top