How do I remove the admin bar (styling) from frontend only?

Question

When logged in, the admin bar adds the following to my page <head> section:

<style media="screen" type="text/css">
    html { margin-top: 28px !important; }
    * html body { margin-top: 28px !important; }
</style>

Now, I can remove this by disabling the admin bar

/* Disable the Admin Bar. */
add_filter( 'show_admin_bar', '__return_false' );

or removing it completely

/* Remove admin bar */
remove_action('init', 'wp_admin_bar_init');

I would like to keep the admin bar in the admin interface and only remove the CSS from front end.

I already use CSS reset where I set margin: 0px, but the admin-bar styling overrides this.

So how can I remove the styling from front end?

PS. I know I can disable the admin bar per user, but that’s not what I want.

--------------------------------------------------

>>> Share a link to this question, just copy and paste the code bellow on your web page <<<

<a href="https://www.wptricks.com/question/how-do-i-remove-the-admin-bar-styling-from-frontend-only/">

How do I remove the admin bar (styling) from frontend only?</a>
0
Steven 9 years 0 Answers 34 views 0

Leave an answer