Remove that darn admin bar on default WordPress installs

So I just set up a fresh WordPress install and right away I realized that I need to remove that pesky toolbar at the top of the page, you know which one I mean, this bloody thing:

Every time I install a fresh WordPress installation I completely forget that I hate this darn thing. It’s like Groundhog Day, mostly because I tend to have the memory of a goldfish.* Every time I have to Google “hook to remove admin bar WordPress” and then go through all of the results which are mostly not what I am looking for, etc.

Solution? Well now that I have a personal blog, I should use it as a resource for myself, since nobody probably will read it any time soon. That being said, I drafted my own 2 line solution to add to my theme’s  functions.php and know that I can just go to my blog next time I perform a fresh install of WordPress.

The code is as follows:

function remove_the_darn_admin_bar(){return false;} add_filter( 'show_admin_bar' , 'remove_the_darn_admin_bar');

A quick explanation of the code, I created a function (remove_the_darn_admin_bar()) that returns false and hooked it into the filter “show_admin_bar.” In short, without getting into a detailed explanation about action vs. filter, that “passes data through” (hat tip to the WordPress codex). Essentially since I return “false” it puts in place of the show_admin_bar hook nothing, thus, no admin bar! Yay!

* Some scientists beg to differ with the notion that goldfish have poor memories.

2 Responses to “Remove that darn admin bar on default WordPress installs”

  1. Wordpress Goldfish and Me

    [...] can imagine my total surprise when I stumbled upon this post by Mat Garango (Remove that darn admin bar on default WordPress installs)—while looking for something totally unrelated and no, I can’t say what, I don’t [...]

  2. ZuzaLeonska

    I could not believe my eyes — someone else hates the adim panel! You made my day: code that works, goldfish, a well written pet peeve AND Groundhog Day. My Koi and goldfish know I will be feeding them from the spot I tap rocks. New fish dash to the spot I normally feed, but a fishing dachshund means this location can be dangerous. It doesn’t take them long to learn to zip over to a safer dining zone.

    Have a wonderful sunny spring
    ZuzaLeonska in northern BC Canada


Leave a Reply