Hide admin top bar from front-end in wordpress

Image

Hello Friends,

This problem was faced when my client said that he don’t want top bar on front-end. So it is easy to do that, Just paste this code into functions.php in your theme folder.

Here’s my code :-

// Disable Admin Bar

if (!function_exists(‘tp_disable_admin_bar’))

{

function tp_disable_admin_bar()

{ // for the admin page

remove_action(‘admin_footer’, ‘wp_admin_bar_render’, 1000); // for the front-end

remove_action(‘wp_footer’, ‘wp_admin_bar_render’, 1000); // css override for the admin page function remove_admin_bar_style_backend()

{

echo ‘<style>body.admin-bar #wpcontent, body.admin-bar #adminmenu { padding-top: 0px !important; }</style>’;

}

add_filter(‘admin_head’,’remove_admin_bar_style_backend’); // css override for the frontend function remove_admin_bar_style_frontend()

{

echo ‘<style type=”text/css” media=”screen”> html { margin-top: 0px !important; } * html body { margin-top: 0px !important;} </style>’;

}

add_filter(‘wp_head’,’remove_admin_bar_style_frontend’, 99);

}

}

add_action(‘init’,’df_disable_admin_bar’);

Now your problem sorted. Enjoy 🙂

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s