WordPress at Your Fingertips

WordPress Admin Bar (Toolbar) Not Showing on Frontend

There are cases when the admin bar (toolbar) of WordPress is not displayed in the front part of the site.

This problem may arise for a number of reasons, below I will consider all the possible reasons why the top admin bar of WordPress may not work.

#1 Make sure your theme has features:

In the header.php file:

<?php wp_head(); ?>

And in the footer.php file:

<?php wp_footer(); ?>

#2 Make sure your profile is checked in the settings: Users > Profile:

#3 Some themes may disable the site's top bar.

And it does not work, even if there are calls to functions wp_head() and wp_footer(). To solve this problem you need to force the display of WordPress admin bar via a hook.

add_action('init', 'admin_bar' );

function admin_bar(){

	if( is_user_logged_in() ){
		add_filter( 'show_admin_bar', '__return_true' , 1000 );
	}
}

#4 The toolbar is often visible only to the administrator.

And it may be that you are not authorized in the front-end, but you are authorized in the admin panel.

Authorization cookies are set separately for front and admin, so it may happen that you are authorized in admin bar, but at the same time are not authorized in the external part of the site, and therefore the admin bar is not displayed.

To solve this problem, simply log out of the site and log in again.

#4 If nothing works

the admin bar is still needed, you can try to turn it on using the show_admin_bar() function:

if ( is_user_logged_in() ) {
	show_admin_bar( true );
}

--

Also, familiarize yourself with the related functions:

  • is_admin_bar_showing() — Determine whether the admin bar should be showing.
  • show_admin_bar() — Allows you to disable the "Toolbar" (Admin Bar). Technically, the function enables/disables "Admin Bar" for the front-end. You cannot turn it off in Admin-panel.
  • WP_Admin_Bar() — Core class used to implement the Toolbar API.

And hooks https://wp-kama.com/hooks/hooks-db?filter=admin_bar

No comments
    Log In