Hide WordPress Admin Bar

WordPress automatically adds an admin bar at the top of each page for all logged in users. This bar can be annoying sometimes.. However it’s very useful if you are an editor and you’d like to edit the current post being browsed, or the current category you’re viewing, you’ll find the corresponding edit link in this admin bar.

If you’d like to completely remove it, add the following snippet to your functions.php

add_filter( 'show_admin_bar', '__return_false' );

Or

You can remove it for everyone else except for the users that has the right to edit posts by adding the following to your functions.php

add_action( 'init', 'ba_hide_admin_bar' );
function ba_hide_admin_bar() {
    if ( ! current_user_can( 'edit_posts' ) ) {
        show_admin_bar( false );
    }
}