wordpress為了方便管理員快速的從前臺(tái)進(jìn)入后臺(tái)來(lái)管理網(wǎng)站在wordpress頂部強(qiáng)制加入了一個(gè)工具條(admin bar),,而且默認(rèn)是對(duì)所有用戶都顯示的,有時(shí)候看著挺煩心,。
那么怎么來(lái)去除這個(gè)煩人的工具條(admin bar)呢?下面附上代碼,。
一,、完全禁用工具條:
1、完全去除wordpress工具條(代碼一)
show_admin_bar(false);
完全去除wordpress工具條(代碼二)
add_filter('show_admin_bar', '__return_false');
2,、只對(duì)特定用戶顯示工具條
只對(duì)管理員顯示
if (!current_user_can('manage_options')) { add_filter('show_admin_bar', '__return_false');}
只對(duì)管理員和編輯顯示
if (!current_user_can('edit_posts')) { add_filter('show_admin_bar', '__return_false');}
3,、將工具條從頂部移至頁(yè)腳
function fb_move_admin_bar() { echo ' <style type="text/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 .quicklinks .menupop ul { bottom: 28px; } </style>';}// 如果你想讓工具條顯示在后臺(tái)頂部,請(qǐng)刪除這行代碼add_action( 'admin_head', 'fb_move_admin_bar' );//如果你想讓工具條顯示在前臺(tái)頂部,,請(qǐng)刪除這行代碼add_action( 'wp_head', 'fb_move_admin_bar' );
以上代碼都是加入到functions.php中即可,。