0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

wordpressでデフォルトの管理画面(wp-admin)以外に管理者用のページを書きたいけどadmin-barはとっておきたい、という時の対処方法

Last updated at Posted at 2015-03-04

以下のコードをfunctions.php あたりに実装すればOK。

この場合、WPにログインした状態で、http://yourdomain.com/hogehoge
にアクセスした場合に、WP謹製のadmin-barが表示される。

functions.php
add_filter("show_admin_bar", function(){
 return is_page("hogehoge") AND is_user_logged_in()? true: false;
});

なにが嬉しいかと;

たとえば、サイト固有の管理ページを作ったとして、でも、WPのそなえつけの管理画面に埋め込みたくない(例えばwp-admin/some_plugin_page/みたいに)、管理ページのデザインを自由に作りたい、でも、ユーザーにはWPにログインしていることをアピールしたい、ってな場合には有効だと、思う。

ああ、まわりくどい、要は、つまり、WPの固有ページに、自由にWPのadmin-barを設置できますよ、と。しかも、それはけっこう嬉しくね?!って話。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?