Vous cherchez un moyen de personnaliser l’ordre du menu administrateur ? Ce snippet vous permettra de modifier l’ordre des éléments du menu administrateur.
Instructions:
- Ajoutez ce code au fichier functions.php de votre thème ou dans un plugin spécifique à votre site.
- Modifiez l’ordre des chaînes dans le tableau retourné aux lignes 4 à 13 pour changer l’ordre des éléments du menu d’administration.
function custom_menu_order($menu_ord) { if (!$menu_ord) return true; return array( 'index.php', // this represents the dashboard link 'edit.php?post_type=events', // this is a custom post type menu 'edit.php?post_type=news', 'edit.php?post_type=articles', 'edit.php?post_type=faqs', 'edit.php?post_type=mentors', 'edit.php?post_type=testimonials', 'edit.php?post_type=services', 'edit.php?post_type=page', // this is the default page menu 'edit.php', // this is the default POST admin menu ); } add_filter('custom_menu_order', 'custom_menu_order'); add_filter('menu_order', 'custom_menu_order');
Note : Si c’est la première fois que vous ajoutez des extraits de code dans WordPress, veuillez consulter notre guide sur la manière de copier/coller correctement des extraits de code dans WordPress, afin de ne pas endommager accidentellement votre site.
Si vous avez aimé cet extrait de code, n’hésitez pas à consulter nos autres articles sur le site comme : Comment créer correctement une page de connexion personnalisée sur WordPress (étape par étape).
Do I have to past it into a specific place in the functions.php? I am using the theme Twenty Thirteen and it’s not working for me.
Thanks, it worked like a charm!!! I really didn’t like the default WP Admin order, or top level menu names for that matter, so with the help of your code and another tutorial, I got it pretty much just the way I want it. I think it’s going to be more user-friendly and intuitive for my clients.
Peace.
Hi Kevin!
How can I include a menu created by a plug-in into the array?
I’m trying “admin.php?page=chat” but doesn’t work.
Thanks!
I’m having the same problem!
Solved!! Instead of “admin.php?page=chat” put only “chat” – Simple as that!
doesn’t work for me =(
Hello, Thanks for the script, just one question?
When using above code, all menus appear below each other. Is there a way to add the divider after few menus just like the default menu in WordPress?
Yes you can do this however it is a little bit of work to get things right. I found a tutorial online that should help you get things going.
http://wordpress.stackexchange.com/questions/2666/add-a-separator-to-the-admin-menu
It’s actually really easy if you can live with the default number of separators (i.e. two) – just use ‘separator1’ and ‘separator2’ in the array instead of a php filename.
Perfect! Most elegant solution on Google, so far
Thanks glad I could help out.
[…] This post was mentioned on Twitter by WPSNIPP. WPSNIPP said: #wordpress Customize admin menu order http://bit.ly/hLr3ga #blog please RT 🙂 […]