Wordpress: change admin submenu

I created and registered the administrative page as a submenu in the Administrator's Messages menu. But the problem is that it comes at the end of the wp submenu (i.e., after the "Tags"),

How to change the order of this submenu of the user admin page that appears after "Add new"?

I use this function to register my submenu in the menu edit.php (Posts)

add_submenu_page( 'edit.php', "my custom submenu", "my custom submenu", CAPABILITY, 'my_custom_submenu', "scrollcore_newsroom_articles" ); 
+6
source share
1 answer

Found a solution, just need to add this function to your functions. php

 /*Change menu-order*/ add_filter( 'custom_menu_order', 'so_18766477_submenu_order' ); function so_18766477_submenu_order( $menu_ord ) { global $submenu; // Enable the next line to see all menu orders //echo '<pre>'.print_r($submenu,true).'</pre>'; $arr = array(); $arr[] = $submenu['edit.php'][5]; //my original order was 5,10,15,16,17,18 $arr[] = $submenu['edit.php'][10]; $arr[] = $submenu['edit.php'][18]; $arr[] = $submenu['edit.php'][17]; $arr[] = $submenu['edit.php'][15]; $arr[] = $submenu['edit.php'][16]; $submenu['edit.php'] = $arr; return $menu_ord; } 

Here, by choosing edit.php, I customize the Messages menu. You can select any file that you want to change its submenu, for example, plugins.php, themes.php, tools.php, etc.

+12
source

Source: https://habr.com/ru/post/953709/


All Articles