Moving the WordPress Admin Bar to the Footer

Moving the WordPress Admin Bar to the Footer

When you are logged into WordPress, you can see various admin menus or an admin bar that you can use to speed up navigation located at the top of the screen.

Memindahkan Admin Bar WordPress ke Footer - 0

However, if you want to use a different layout, you can also easily change or move the location of the WordPress admin bar to the footer.

To do this, it is recommended to use a theme that allows for customization. If you are using a theme that already uses a block editor like Twenty Twenty-Three, you will need to add an HTML block manually to every page.

It is also recommended to use a Child Theme so that when you update your theme, the changes you have saved are not lost [How to Create a WordPress Child Theme].

1. Theme Customization

Once you have confirmed that the theme you are using supports customization, you can perform the customization directly through the Appearance > Customize page, or you can also click customize directly from the main WordPress page when you are logged in.

Memindahkan Admin Bar WordPress ke Footer - 1

2. Add Custom CSS

Once you are on the theme customization page, you can then add custom CSS by looking for the option Additional CSS, and later you can add custom CSS to move the location of the WordPress admin bar to the footer.

Memindahkan Admin Bar WordPress ke Footer - 2

If you have found that option and opened it, you can add the following custom CSS.

body {margin-top: -28px;padding-bottom: 28px;}body.admin-bar #wphead {padding-top: 0;}body.admin-bar #footer {padding-bottom: 28px;}#wpadminbar { top: auto !important;bottom: 0;}#wpadminbar .menupop .ab-sub-wrapper { bottom: 32px; }

Just save the changes and they will be applied afterward.

3. Check the Changes

Now you can exit the theme customization page and check the change in the location of the WordPress admin bar, which was previously at the top of the screen and is now at the bottom.

Memindahkan Admin Bar WordPress ke Footer - 3

While that method does work, the website display will be cut off or shifted up by 28px even when accessed while logged out.

Alternatively, you can use the following code and add it to the file functions.php to display the code only when accessed by a logged-in user. Conversely, when accessed without logging in, the CSS will not be executed.

function wpg_ubah_posisi_admin_bar() {if (is_user_logged_in()) {    ?>  	<style>  		body {margin-top: -28px;padding-bottom: 28px;}  		body.admin-bar #wphead {padding-top: 0;}  		body.admin-bar #footer {padding-bottom: 28px;}  		#wpadminbar { top: auto !important;bottom: 0;}  		#wpadminbar .menupop .ab-sub-wrapper { bottom: 32px; }  	</style>	<?php	}	else{}	}
add_action('wp_head', 'wpg_ubah_posisi_admin_bar');

If you do not know how to add code to functions.php, you can follow this tutorial: How to Add Code to WordPress Functions.

Written by

Muhammad Khoirun Nasikin

I enjoy tinkering with WordPress, hosting, VPS, web development, and various small experiments related to websites. I have over 3 years of experience in the web hosting industry.

COMMENTS

Loading...