This is the basic code. There’s plugins to do it but I prefer to put this in my functions.php
add_action('init', 'remove_admin_bar');
function remove_admin_bar() {
show_admin_bar(false);
}
However I prefer to only remove it if the user isn’t logged in:
add_action('init', 'remove_admin_bar');
function remove_admin_bar() {
if (!is_user_logged_in()) {
show_admin_bar(false);
}
}
Or if you prefer to limit by user roles and editing capabilities.
function remove_admin_bar() {
if (!current_user_can('administrator')) {
show_admin_bar(false);
}
}
FYI: There’s a pretty popular search result recommending this for role check:
add_action('init', 'remove_admin_bar');
function remove_admin_bar() {
if (!current_user_can('administrator') && !is_admin()) {
show_admin_bar(false);
}
}
This would check to see if the user is in the admin portion in which case you’d show the bar as well.
There’s no reason to place this in your functions.php instead of as a plugin. It is the exact same code that gets executed, except as a plugin it is easier to maintain.