X

Supprimer les éléments de menu de la barre d’administration de WordPress 3.3+

Snippets by IsItWP

Voulez-vous supprimer les éléments de menu de la barre d’administration de WordPress 3.3+ ? En ajoutant le code suivant au fichier functions.php de votre thème WordPress, vous pouvez supprimer les éléments de menu de la barre d’administration de WordPress 3.3+.

function wps_admin_bar() {
    global $wp_admin_bar;
    $wp_admin_bar->remove_node('wp-logo');
    $wp_admin_bar->remove_node('about');
    $wp_admin_bar->remove_node('wporg');
    $wp_admin_bar->remove_node('documentation');
    $wp_admin_bar->remove_node('support-forums');
    $wp_admin_bar->remove_node('feedback');
    $wp_admin_bar->remove_node('view-site');
}
add_action( 'wp_before_admin_bar_render', 'wps_admin_bar' );

Nous espérons que ce code vous a aidé à supprimer les éléments de menu de WordPress. Vous pouvez également consulter notre guide sur la suppression des scripts emoji dans la tête de WordPress.

Commentaires   laisser une réponse

  1. I was looking to remove the whole account/user profile box with the “Howdy” text.. replacing it with :logout button” for users

    is that possible?

    1. We don’t have an exact snippet for this. That said, you may want to check out these two snippets:

      https://www.isitwp.com/addremove-wp-admin-bar-links/
      https://www.isitwp.com/replace-howdy-in-wordpress-3-3-admin-bar/

  2. Hi,

    Discovered your site today and already loving it and used a few snippets in a wordpress store I am creating for a client. Excellent stuff!!

    I was wondering if you would be able to post up a snippet in the same vein as this one but with removing/disabling menu admin menu items per user role – for example the editor role we would want to remove items from the admin menu.. Would be great if you could help out on this!

    1. Hi Nick,
      I think you would be looking for something along these lines. I didn’t test this but should work without issue. However you would want to check for other roles so a “switch” may work better than a bunch of if statements.

      global $current_user;
      get_currentuserinfo();
      if (user_can( $current_user, “subscriber”)){
      echo ‘you are subscriber’;
      }

  3. Hi,

    Discovered your site today and already loving it and used a few snippets in a wordpress store I am creating for a client. Excellent stuff!!

    I was wondering if you would be able to post up a snippet in the same vein as this one but with removing/disabling menu admin menu items per user role – for example the editor role we would want to remove items from the admin menu.. Would be great if you could help out on this!

  4. Nice Snippet of code. Can this be done so that it only disappers on certain custom post types?

  5. Here’s some others to add:

    $wp_admin_bar->remove_menu(‘comments’);$wp_admin_bar->remove_menu(‘new-content’);

    1. Cheers, thanks Tom.

    2. Besides removing the logo, these are exactly the two I was looking for, thanks for this!

  6. was an older snippet, has been updated now. Please don’t add links to premium plugins within the comments.

  7. awesome wordpress tip.. now i can remove unwanted link from wordpress admin section, thanks a lot Kevin…

    1. No problem glad see see you like the wordpress snippets 🙂

  8. Zachary Lysobey avril 9, 2012 à 12:33 pm

    Hmm, is there somewhere where there is documentation of all the menu items etc…?  It seems like several of those posted in your article do nothing at all (at least on the backend – my front-end admin bars are disabled).  Even with them all uncommented – the admin bar has nearly as much cruft on it as when I started.

    Its nice to get rid of that wordpress logo though 😉

    1.  What is it that you are looking to remove,

  9. Under the “+ New” menu, I would like to remove the “Post” and “Link” sub-menu items. Is there  a way to do this for the 3.3 Admin bar. The only work-around that I have found is to remove the entire “+ New” by adding

    $wp_admin_bar->remove_menu(‘new-content’);

    to your function. Thanks for sharing!

    1. I got it! Just added the following to your function:

      $wp_admin_bar->remove_menu(‘new-post’);
      $wp_admin_bar->remove_menu(‘new-link’);

  10. Remove Menu Items from WordPress 3.3 Admin Bar | ChurchMag janvier 10, 2012 à 8:41 am

    […] some, you can even remove any plugins that have automatically been added to your Admin Bar.[via WordPress Code Snippets] About Eric Dye: I believe in media that matters. I have produced radio for over 15 years, […]

  11. Remove Menu Items from WordPress 3.3 Admin Bar | ChurchMag janvier 10, 2012 à 8:41 am

    […] some, you can even remove any plugins that have automatically been added to your Admin Bar.[via WordPress Code Snippets] About Eric Dye: I believe in media that matters. I have produced radio for over 15 years, […]

  12. Thanks, that is really helpful! 

    1. Cool Surkho glad to help, enjoy the snippet!

    2. Shamil Abu-Hurairah janvier 4, 2012 à 11:27 am

      huh

Ajouter un commentaire

Nous sommes heureux que vous ayez choisi de laisser un commentaire. N'oubliez pas que tous les commentaires sont modérés conformément à notre privacy policy, et que tous les liens sont en nofollow. N'utilisez PAS de mots-clés dans le champ du nom. Engageons une conversation personnelle et constructive.

WordPress Launch Checklist

L'ultime liste de contrôle pour le lancement de WordPress

Nous avons rassemblé tous les éléments essentiels de la liste de contrôle pour le lancement de votre prochain site Web WordPress dans un ebook pratique.
Oui, envoyez-moi le gratuit !