In: , ,
On: 2010 / 10 / 04 Viewed: 41507 times
Shorter URL for this post: http://ozh.in/tx

It will be a matter of personal preference or a matter of clients asking for it, but I bet this one is going to be a frequent question in the next months: "How do I remove the Admin Bar?".

Ahah. I'm so funny.

This will probably slightly change as this component is heavily under works, but as of now this short plugin will do:

  1. <?php
  2. /*
  3. Plugin Name: No Admin Bar
  4. Plugin URI: http://planetozh.com/blog/2010/10/how-to-remove-wordpress-admin-bar/
  5. Description: Remove the Admin Bar
  6. Author: Ozh
  7. Version: 1.0
  8. Author URI: http://ozh.org/
  9. */
  10.  
  11. // Remove instantiation
  12. add_filter( 'show_admin_bar', '__return_false' );
  13.  
  14. ?>

Either make this a regular plugin in wp-content/plugins/ and activate it, or just drop it in wp-content/mu-plugins/.

Update: now a downloadable plugin.

Update 2: this was a sort of a proof of concept. Now that WordPress 3.1 is released and has a per-user option to disable it, this plugin is incomplete: if you want to disable the admin bar, also hide the option as Pete Mall explains.

Shorter URL

Want to share or tweet this post? Please use this short URL: http://ozh.in/tx

Metastuff

This entry "How To Remove WordPress’ Admin Bar" was posted on 04/10/2010 at 10:36 pm and is tagged with , ,
Watch this discussion : Comments RSS 2.0.

8 Blablas

  1. 1
    Andrew Nacin United States »
    replied, on 05/Oct/10 at 12:04 am # :

    We'll probably reduce this to a single filter. Additionally, we're still going to discuss a UI option.

    As I pointed out here, it's best not to rely on the state of something in trunk until well after feature freeze or until there have been some real iterations.

  2. 2
    Mamaduka Georgia »
    wrote, on 05/Oct/10 at 7:44 am # :

    Useful thing Ozh.

    Nacin it would be great UI option and much easier to manage admin bar.

  3. 3
    Frank Germany »
    said, on 05/Oct/10 at 10:43 am # :

    Your plugin remove only the css and the init. What is with the scripts (wp_admin_bar_js) and the redering? I think, the admin-bar is current an alpha-version, i hope it give an option or one hook for frontend and one for backend zo include all functions.

  4. 4
    Stephanie Canada »
    replied, on 26/Nov/10 at 6:26 pm # :

    I just installed the 3.1beta1 and the very first question on my mind was 'how do I get rid of this admin bar?!'

    Thanks for posting the answer. I've added the remove_action to my theme functions, works like a charm.

    They really really should make this an option in Settings, and default it to "off". It is very uncool to add stuff to the live side of a site without asking. Even if it is something only seen by logged-on admins, it is just a bad idea to surprise people with unexpected 'additions' to their site.

  5. 5
    Frank Germany »
    thought, on 01/Dec/10 at 10:04 am # :

    This code is enough, since WP 3.0.0
    add_filter( 'show_admin_bar', '__return_false' );

    Best regards

  6. 6
    Wes United States »
    replied, on 27/Feb/11 at 12:48 am # :

    Thanks for the info, it helped me and I then wrote a plugin to help give people more control without much work: WP Custom Admin Bar

    You can control who can see the admin bar by user role and disable it for a single browsing session or on a single page.

  7. 7
    David United States »
    replied, on 01/Mar/11 at 5:00 pm # :

    Thank you so much, am going to naturally add "add_filter( 'show_admin_bar', '__return_false' );"

    to all of my themes now… the admin bar is so damn annoying, its features like the admin bar that should be left kept as a Plugin, and not a part of wordpress, I am sure other developers agree.

  8. 8
    Álvaro Degives-Más United States »
    said, on 14/Apr/11 at 12:19 am # :

    Agreed with David – the hamfisted behavior of certain WP core developers in the manner they add unnecessary and arbitrary bloatware to WP are a wonderful way to drive people off to a competing CMS.

    Then again, fortunately there are great people also like Ozh jumping in to mitigate the damage of their bone-headed peers. Thanks for the fix, Ozh; what pity you had to spend time on fixing a WP design flaw.

Leave a Reply

Comment Guidelines or Die

  • HTML: You can use these tags: <a href=""> <em> <i> <b> <strong> <blockquote>
  • Posting code: Post raw code (no <> &lt; etc) within appropriate tags : [php][/php], [css][/css], [html][/html], [js][/js], [sql][/sql], [xml][/xml], or generic [code][code]
  • Gravatars: Curious about the little images next to each commenter's name ? Go to Gravatar.
  • Spam: Various spam plugins on patrol. I'll put pins in a Voodoo doll if you spam me.
  • I will mark as Spam test comments, all comments with SEO names (ie "My Cool Online Shop" instead of "Joe") or containing forum-like signatures.

Read more ?