Wordpress

WordPress Admin Bar CSSの削除

以前のバージョンの時、WordPressはログインユーザー用のツールバーを、サイトのテーマに沿った表示側に追加となっていました。 その理由はわかりますが、とても迷惑なもので、見る気にもなりません。 このタスクを達成するために、WordPressはすべてのページに次のようなものを注入します。

<style type="text/css" media="print">#wpadminbar { display:none; }</style>
<style type="text/css" media="screen">
	html { margin-top: 32px !important; }
	* html body { margin-top: 32px !important; }
	@media screen and ( max-width: 782px ) {
		html { margin-top: 46px !important; }
		* html body { margin-top: 46px !important; }
	}
</style>

このCSSと管理バーを削除するには、functions.phpファイルの中にある以下のコードを使用します。

add_action('get_header', 'remove_admin_login_header');
function remove_admin_login_header() {
	remove_action('wp_head', '_admin_bar_bump_cb');
}

使ってみてください。

Follow me!

-Wordpress

PAGE TOP