开发者

WordPress Admin Nav Showing in Frontend

开发者 https://www.devze.com 2023-03-01 18:27 出处:网络
Anyone know how to remove the admin navigation links from the frontend? I\'ve built a custom theme and when I am logged in to WordPress, WordPress is appendin开发者_Go百科g the admin nav bar somewhere

Anyone know how to remove the admin navigation links from the frontend? I've built a custom theme and when I am logged in to WordPress, WordPress is appendin开发者_Go百科g the admin nav bar somewhere.


The admin bar? Go to Users > Your Profile > Show Admin Bar. Here you can disable it from your theme. If you want to completely disable (remove) it, use one of various plugins, like this.


Or you can remove it by default in functions.php.

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

<?php function yoast_hide_admin_bar_settings() { ?>
<style type="text/css">
    .show-admin-bar {
        display: none;
    }
</style>
<?php }

function yoast_disable_admin_bar() {
add_filter( 'show_admin_bar', '__return_false' );
add_action( 'admin_print_scripts-profile.php',
     'yoast_hide_admin_bar_settings' );
}
add_action( 'init', 'yoast_disable_admin_bar' , 9 );

Thanks to Yoast (http://yoast.com/disable-wp-admin-bar/)


Just this alone in the functions.php works for me.

// Remove Admin Bar Front End
add_filter('show_admin_bar', '__return_false');


For wordpress 3.4.2, none of these workarounds should work. I have sorted out a very simple trick to hide the admin bar!

Just after you call the wp_head(), place this style declaration:

<style>
    html { margin-top: 0px !important; }
    * html body { margin-top: 0px !important; }
</style>

It involves no modification to the functions or whatever. Just plain old css!! I hope it solves the Googler's problem in near future :-)


Put this in your functions.php:

/* Disable WordPress Admin Bar for all users but admins. */
if(!current_user_can("manage_options")){
     show_admin_bar(false);
}


You can do this by plugin, link below:

http://wordpress.org/plugins/global-admin-bar-hide-or-remove/

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号