Admin Bar Tricks
-
According to our latest poll, so far the votes are pretty much split on whether people love, hate, or don’t care about WordPress’ new Admin Bar. Over time, it looks like “Hate it” has started to pull ahead, but it doesn’t matter because the Admin Bar is here to stay, regardless of opinion. Already there are many awesome ways to make it do virtually whatever you want. In this DigWP post, we round up a ton of tips, tricks, and plugins for ultimately mastering the WordPress Admin Bar.
Here is our menu of Admin Bar Tricks for WordPress 3.1 and better:
- Disable the Admin Bar for individual users
- Disable the Admin Bar for all users of the current theme
- Disable the Admin Bar for non-Admins only
- Always show the Admin Bar
- Move the Admin Bar to the bottom
- Add or Remove links from the Admin Bar
- Clean up User Profile Page
- Disable and Customize the Admin Bar with Plugins
- Even More Admin Bar Resources
Disable the Admin Bar for individual users
By default, each registered user has the option of showing the Admin on the frontend and/or back-end of the site. Thus, to change your preferences, just visit Users > Your Profile and choose your options as seen here:
![[ Screenshot: Admin Bar Settings ]](http://digwp.com/wp-content/blog-images/admin-bar-settings.gif)
Unfortunately, this gets kind of tedious when customizing profiles for many users. Fortunately, we’re just getting started, so read ahead to see more efficient ways of disabling and modifying the WordPress Admin Bar.
Disable the Admin Bar for all users of the current theme
To cleanly disable the Admin Bar for all users of your theme (and thus your site), add this snippet to your theme’sfunctions.phpfile:
Alternately, you may use this method, which filters the// disable the admin bar show_admin_bar(false);show_admin_barfunction:
Another option is to hide the Admin Bar using CSS. To do so, paste this into your// disable the admin bar add_filter('show_admin_bar', '__return_false');
theme’sstyle.css(or other stylesheet):
/* hide the admin bar */ #wpadminbar { display:none; }Disable the Admin Bar for non-Admins only
Expanding on the previous example, here are two snippets that disable the Admin Bar for non-Admins and Editors. Place either of the following infunctions.php:
As you might guess, any setting may be used for// show admin bar only for admins if (!current_user_can('manage_options')) { add_filter('show_admin_bar', '__return_false'); } // show admin bar only for admins and editors if (!current_user_can('edit_posts')) { add_filter('show_admin_bar', '__return_false'); }current_user_can(), so it’s easy to show/hide the Admin Bar for any particular group of users.
Clean up User Profile Page
After disabling the Admin Bar, you may want to hide its display settings in each user’s Profile Page. The easiest way to do this is with a simple function:
Just place that in your theme’sfunction hideAdminBar() { ?> add_action('admin_print_scripts-profile.php', 'hideAdminBar');functions.phpand you’re good to go. No more Admin Bar Settings displayed in the Admin area.
Always show the Admin Bar
Follow the white rabbit shows us how to show the Admin Bar even when logged out. As a bonus, a handy “Log in” button is added to the bar for easy maneuvering. Just add the following snippet to your theme’sfunctions.phpfile:
You can see it in action at follow the white rabbit.// always show admin bar function pjw_login_adminbar( $wp_admin_bar) { if ( !is_user_logged_in() ) $wp_admin_bar->add_menu( array( 'title' => __( 'Log In' ), 'href' => wp_login_url() ) ); } add_action( 'admin_bar_menu', 'pjw_login_adminbar' ); add_filter( 'show_admin_bar', '__return_true' , 1000 );
Move the Admin Bar to the bottom
Want to display the Admin Bar at the bottom of the page instead of the top? WPengineer shows us how with this bit of CSS via thefunctions.phpfile:
This code adds the required CSS to both the front-end (public pages) and back-end (admin pages). To disable for one or the other, just comment-out or remove the corresponding// move admin bar to bottom function fb_move_admin_bar() { ?> // on backend area add_action( 'admin_head', 'fb_move_admin_bar' ); // on frontend area add_action( 'wp_head', 'fb_move_admin_bar' );add_action()line near the end of the code. You could also just copy/paste the CSS into your theme’sstyle.cssfile if you only need to move it on the front-end of your site. An even easier way is provided by Coen Jacobs’ Stick Admin Bar To Bottom plugin that makes it happen automagically.
Add or Remove links from the Admin Bar
WPMU.org shows us how to add/remove links from the Admin Bar. This is especially useful for MultiSite networks, where all of the extra links may not be necessary. The following code may be used to remove links and/or menus (viafunctions.php:
For this example, we use// remove links/menus from the admin bar function mytheme_admin_bar_render() { global $wp_admin_bar; $wp_admin_bar->remove_menu('comments'); } add_action( 'wp_before_admin_bar_render', 'mytheme_admin_bar_render' );remove_menu('comments')to remove the comments dropdown list. To remove a different link/menu, check/wp-includes/admin-bar.phpfor the corresponding ID. Here’s a list of some of them to get you started:
my-account– link to your account (avatars disabled)my-account-with-avatar– link to your account (avatars enabled)my-blogs– the “My Sites” menu if the user has more than one siteget-shortlink– provides a Shortlink to that pageedit– link to the Edit/Write-Post pagenew-content– link to the “Add New” dropdown listcomments– link to the “Comments” dropdownappearance– link to the “Appearance” dropdownupdates– the “Updates” dropdown
functions.phpfile:
You’ll want to adjust the parameters to fit your needs, and don’t forget to see the Codex for additional information. For even more insight into this technique, see WPengineer’s post on adding menus to the Admin Bar.// add links/menus to the admin bar function mytheme_admin_bar_render() { global $wp_admin_bar; $wp_admin_bar->add_menu( array( 'parent' => 'new-content', // use 'false' for a root menu, or pass the ID of the parent menu 'id' => 'new_media', // link ID, defaults to a sanitized title value 'title' => __('Media'), // link title 'href' => admin_url( 'media-new.php') // name of file 'meta' => false // array of any of the following options: array( 'html' => '', 'class' => '', 'onclick' => '', target => '', title => '' ); )); } add_action( 'wp_before_admin_bar_render', 'mytheme_admin_bar_render' );
Disable and Customize the Admin Bar with Plugins
Almost immediately after the Admin Bar was added to the WordPress core, plugins started popping up to disable it, move it, minimize it, and more. Here’s a quick list of plugins and links for ultimate control over the Admin Bar.
If you know of others, mention them in the comments and we’ll add them to the list!
View Making Money Adsense's Profile
Subscribe via RSS
There are no related articles.
Digg itStumble del.icio.usredditYahooGoogle
Tags
News & Update
Register Your email to receive news Posts !
Blog Archive
-
▼
2011
(24)
-
►
April
(15)
- Earn More with Adsense: Tips & Layout Optimization...
- Google Chrome 11.0.696.57 Stable Released - Direct...
- Thesis Tutorial – Custom Post Dates
- 5 Google Adsense Secrets, Tips and Tricks
- Google Adsense Tips, Tricks, and Secrets
- How to Get More Subscribers for Your Email List
- Is Commenting on Blogs a Smart Traffic Strategy?
- 101 Ways to Build Link Popularity
- 5 Tips To Increase Your Adsense Revenue
- Basic Adsense Tips
- Greatest Blog Design Inspiration of 2010
- 101 Web Marketing Ideas and Tips
- How to Attract Links and Increase Web Traffic – Th...
- How to Increase Website Traffic
- How To Make Money With Google Adsense
-
►
April
(15)
-
►
2010
(9)
-
►
May
(9)
- 9 Tricks I Used To Triple My AdSense Earnings In 3...
- New Adsense Tips
- Top 15 AdSense tips
- 100% Google AdSense: Tools, Tips and Resources
- Earn More with Adsense: Tips & Layout Optimization...
- Google Adsense Tips, Tricks, and Secrets
- Google AdSense Tips
- How to Increase Website Traffic
- Top Paying Google Adsense Keywords List
-
►
May
(9)


