admin管理员组

文章数量:1391989

I am trying to move the WP Admin bar on the front end to below my themes main header navigation, as well as make it the same width.

I am using the GeneratePress theme and am getting support from them to achieve this, however we’re stuck.

Here’s what they said, “ I just dug through the core WordPress code for the admin bar hoping to find a way to unhook the current position and move it somewhere else, but I came up empty.

Basically, we need to unhook the bar from the current position and hook it into a different action.”

Any ideas on how to achieve this?

I am trying to move the WP Admin bar on the front end to below my themes main header navigation, as well as make it the same width.

I am using the GeneratePress theme and am getting support from them to achieve this, however we’re stuck.

Here’s what they said, “ I just dug through the core WordPress code for the admin bar hoping to find a way to unhook the current position and move it somewhere else, but I came up empty.

Basically, we need to unhook the bar from the current position and hook it into a different action.”

Any ideas on how to achieve this?

Share Improve this question asked Feb 25, 2020 at 17:13 deleted-userdeleted-user 312 bronze badges 2
  • 1 I would just update the CSS. You don't need to change the action to change the position. – Cornel Raiu Commented Feb 25, 2020 at 17:38
  • found an old topic related to your question: wordpress.stackexchange/questions/15444/… (not tested) – Michael Commented Feb 26, 2020 at 3:19
Add a comment  | 

1 Answer 1

Reset to default 5

The admin bar is hooked to wp_footer. So …

remove_action( 'wp_footer', 'wp_admin_bar_render', 0 );

… will remove it from there. And then you can register it for a custom hook with:

add_action( 'my_custom_hook', 'wp_admin_bar_render', 1000 );

You still have to overwrite the CSS in your stylesheet, but that should be fairly simple.

Oh, and welcome to WordPress Stack Exchange! :)

本文标签: navigationMove WP Admin Bar