How to work with me

[ad name=”Adsense – text only”] I prefer to work fast, minimize bullshit, get to the point. You will sometimes have bad news for me. I want it immediately. I can usually show you how to fix it. And I never blame the messenger. Bring pen and paper to every meeting with me. Pay attention to… Continue reading How to work with me

Oh, already forgot this article in my drafts:

Since WordPress 3.1, a lot of new cool features were added. One of the most hated loved ones is the admin-bar. In this article I will cover some of the basic hooks to modify it to suit your needs.
Let’s go:

[ad name=”Adsense – text only”]

How to Disable the Admin-Bar

The developers of WordPress made it really easy for you to disable the admin-bar. Simply go to Users > Your Profile and find the section where it says “Show Admin Bar” and tick your choice.
But this is just saved for each users separately. If you are working on a site for a client and you want to get rid of it for each user, then simply open your theme’s function.php and paste the following code:


This will get rid of the admin-bar – if you want to remove the settings in the user profile too, just append this code:

function hideAdminBar(){
    echo "<style type='text/css'>";
    echo "  .show-admin-bar {display:none;}";
    echo "</style>";

Change the CSS (Move to bottom)

By default, the bar shows on top of each page when you are logged in. If you don’t like that, you can hook your own CSS to the admin-bar and move it to the bottom (and do some more crazy stuff with it).
Simply add this code to your functions:

function adminBarCSS() {
        echo "
        <style type='text/css'>
             html { padding-bottom: 28px !important; }
             body { margin-top: -28px; }
             #wpadminbar {  top: auto !important; bottom: 0; }
             #wpadminbar .quicklinks .menupop ul { bottom: 28px; }
add_action('admin_head', 'adminBarCSS');
add_action('wp_head', 'adminBarCSS');

Now it’s up to you to do some more interesting stuff (like moving the bar to the left/right, let it float, or whatever).

Remove Links from the Admin-Bar

If you want to (or need to) remove links in the admin-bar. this small function will help you:

function myAdminBarRender() {
    global $wp_admin_bar;
add_action( 'wp_before_admin_bar_render', 'myAdminBarRender' );

The way this works is just to provide the IDs for each link to the remove_menu() function.
You can find all default links in /wp-includes/admin-bar.php.

Some of the defaults are:

  • my-account / my-account-with-avatar – the first link, to your account
  • my-blogs – the ‘My Sites’ menu (for networked blogs)
  • get-shortlink -provides a Shortlink to that page
  • edit – the edit link
  • new-content – the ‘Add New’ drop down
  • comments – the ‘Comments’ drop down
  • appearance – the ‘Appearance’ drop down
  • updates – the ‘Updates’ drop down

Add Links to the Admin-Bar

Here you have a simple way of putting custom links into the admin-bar.

function myAdminBarRender() {
    global $wp_admin_bar;
        $wp_admin_bar->add_menu( array(
        'parent' => 'new-content',
        'id' => 'new_media',
        'title' => __('Media'),
        'href' => admin_url( 'media-new.php')
    ) );
add_action( 'wp_before_admin_bar_render', 'myAdminBarRender' );

You even can create a custom drop down menu in the admin-bar – just take a look at Michael Martins tutorial to get you started.

That’s it for now – now go and pimp your admin-bar! :)