Don’t get me wrong. I love the Admin Bar that WordPress shows on sites that I maintain. But, there are a few things that I want to change.
function move_admin_bar() {
if (is_admin_bar_showing()) {
echo '';
}
}
add_action( 'wp_head', 'move_admin_bar' );
Stepping through the code, first it checks if the Admin Bar is being displayed. If so, it continues. If not, nothing else happens.
Then, it checks if the current device is a mobile device. If so, it hides the Admin Bar and shifts the BODY tag to hide the empty space. If not, it attaches the Admin Bar to the bottom of the screen.
To run this code, copy it to the functions.php in your current theme.
And, as a bonus, if you want to change the color of the Admin Bar to match your theme, put the following code into your style.css file in your current theme.
div#wpadminbar {
background-color: #461451 !important;
}
Happy editing 🙂
A ridiculous amount of caffeine was consumed while researching.
Add some fuel if you would like to help keep me going!