Title: 投稿者(author)別にページデザインを変えるには？
Last modified: 2008年3月27日

---

# 投稿者(author)別にページデザインを変えるには？

 *  解決済 [under](https://ja.wordpress.org/support/users/under/)
 * (@under)
 * [18年、 7ヶ月前](https://ja.wordpress.org/support/topic/%e6%8a%95%e7%a8%bf%e8%80%85author%e5%88%a5%e3%81%ab%e3%83%9a%e3%83%bc%e3%82%b8%e3%83%87%e3%82%b6%e3%82%a4%e3%83%b3%e3%82%92%e5%a4%89%e3%81%88%e3%82%8b%e3%81%ab%e3%81%af%ef%bc%9f/)
 * アーカイブページ（archive.php)、単一記事ページ（single.php)
    それぞれ投稿者(author)
   別にデザインテンプレートを用意して変えたいのですが、 URLから判別を受けて表示する
   テンプレートを切り替えるにはどうすればよいでしょうか？？
 * 現状カスタムパーマリンクを使用しておりまして
    [http://www.xxx.com/contents/%author%/%category%/%postname%/](http://www.xxx.com/contents/%author%/%category%/%postname%/)
   このような形にURLを吐き出しています。
 * ので
    author1のアーカイブページは [http://www.xxx.com/contents/author/author1/](http://www.xxx.com/contents/author/author1/)
 * author1の書き込んだcategory-aに属する記事は
    [http://www.xxx.com/contents/author1/category-a/](http://www.xxx.com/contents/author1/category-a/)
 * といったURLで表示がされています。
 * [http://www.xxx.com/contents/author/author1/](http://www.xxx.com/contents/author/author1/)
   
   [http://www.xxx.com/contents/author1/category-a/](http://www.xxx.com/contents/author1/category-a/)
   などの場合はテンプレートA(archve-author1.php)
 * [http://www.xxx.com/contents/author/author2/](http://www.xxx.com/contents/author/author2/)
   
   [http://www.xxx.com/contents/author2/category-a/](http://www.xxx.com/contents/author2/category-a/)
   の場合はテンプレートB(archve-author2.php)
 * [http://www.xxx.com/contents/author/author3/](http://www.xxx.com/contents/author/author3/)
   
   [http://www.xxx.com/contents/author3/category-a/](http://www.xxx.com/contents/author3/category-a/)
   の場合はテンプレートC(archve-author3.php)
 * といった振り分けは可能でしょうか？
 * [http://www.xxx.com/contents/?author=3](http://www.xxx.com/contents/?author=3)
   
   [http://www.xxx.com/contents/?author=3&cat=1](http://www.xxx.com/contents/?author=3&cat=1)
   こういうURLで判別受け取れるかと思ったんですが、上記の形式でアクセスすると [http://www.xxx.com/contents/author/author3/](http://www.xxx.com/contents/author/author3/)
   [http://www.xxx.com/contents/author3/category-a/](http://www.xxx.com/contents/author3/category-a/)
 * という形式のURLにリダイレクトがかかる状況です。

12件の返信を表示中 - 1 - 12件目 (全12件中)

 *  [Yuriko IKEDA](https://ja.wordpress.org/support/users/lilyfan/)
 * (@lilyfan)
 * [18年、 7ヶ月前](https://ja.wordpress.org/support/topic/%e6%8a%95%e7%a8%bf%e8%80%85author%e5%88%a5%e3%81%ab%e3%83%9a%e3%83%bc%e3%82%b8%e3%83%87%e3%82%b6%e3%82%a4%e3%83%b3%e3%82%92%e5%a4%89%e3%81%88%e3%82%8b%e3%81%ab%e3%81%af%ef%bc%9f/#post-110369)
 * author 表示では author.php を用意しておけば、これが呼び出されます。ただし、author
   別にテンプレートを用意しても無効なので、author.php の先頭で、get_the_author_ID()
   等の結果で振り分けるとよいでしょう。get_the_author…. の他の関数については wp-
   includes/author-template.php を見てみてください。
 * author と category の複合ですが、template-loader.php の仕様で、先にカテゴリー
   テンプレートが呼び出されてしまいます。category-a.php の先頭で author 振り分け
   が必要と思います。
 * あと、余談ですが、ドメイン名の例示には example.com や example.jp 等を使ってくだ
   さい。xxx.com は実在のドメインですので、あなたが xxx.com を所有しているのでない
   限り、サンプルに使うべきではありません。
 *  トピック投稿者 [under](https://ja.wordpress.org/support/users/under/)
 * (@under)
 * [18年、 7ヶ月前](https://ja.wordpress.org/support/topic/%e6%8a%95%e7%a8%bf%e8%80%85author%e5%88%a5%e3%81%ab%e3%83%9a%e3%83%bc%e3%82%b8%e3%83%87%e3%82%b6%e3%82%a4%e3%83%b3%e3%82%92%e5%a4%89%e3%81%88%e3%82%8b%e3%81%ab%e3%81%af%ef%bc%9f/#post-110372)
 * lilyfanさん
 * お返事ありがとうございます。
    ご指摘のドメイン表記の件もご注意ありがとうござい
   ます、 こちら気をつけるようにします。
 * author.phpでauthor表示専用のテンプレートが作れるとは知りませんでした。
    あまり
   スマートでないと思いますが、投稿者別にデザインを変えたい部分は author.php内で
   それぞれ
 *     ```
       <?php elseif ( is_author('1')): ?>
       1
       <?php elseif ( is_author('2')): ?>
       2
       <?php elseif ( is_author('3')): ?>
       3
       <?php else: ?>
       その他
       <?php endif; ?>
       ```
   
 * のような表記で切り分ける形で対応しようと思います。
 * あと振り分けが多くなるとややこしくなりそうなので
    author.phpは全部の投稿者同じ
   テンプレートにして header.phpだけ表示を振り分けようと考えています。 ただこの方法
   だとheader.php内で表示振り分けを行った場合に （パンくずリストを上記の上記の方法
   でheader.php内表示しています。）
 * example.com/contents/author/author1/
    の場合は振り分けがきくのですが、 example.
   com/contents/author3/category-a/ の場合だと振り分けがうまくできないようで。。
   template-loader.phpの仕様と関係あるところなのでしょうか？？
 *  [Yuriko IKEDA](https://ja.wordpress.org/support/users/lilyfan/)
 * (@lilyfan)
 * [18年、 7ヶ月前](https://ja.wordpress.org/support/topic/%e6%8a%95%e7%a8%bf%e8%80%85author%e5%88%a5%e3%81%ab%e3%83%9a%e3%83%bc%e3%82%b8%e3%83%87%e3%82%b6%e3%82%a4%e3%83%b3%e3%82%92%e5%a4%89%e3%81%88%e3%82%8b%e3%81%ab%e3%81%af%ef%bc%9f/#post-110373)
 * > example.com/contents/author3/category-a/
 * ですが、手元の環境では、そもそもコンテンツがうまく表示できませんでした。
 * example.com/contents/?author=3&cat=1
 * からのリダイレクトをすると、example.com/contents/author/author3/ になってしま
   い、カテゴリーの絞り込みが URL に反映されません…… (WordPress 2.3.3 だから?)。
 * template-loader.php の仕様というのは、is_category() のチェックが is_author() 
   のチェックより先なので、カテゴリーテンプレートが先に読まれるということです。is_category()
   や is_author() を TRUE にする処理は wp-includes/query.php で行なっていて、排他
   的ではなく両立するはずです。ただ、リダイレクトされたあとの URL が、is_category()
   が TRUE にならない型式になってしまっている可能性はあります。
    このへんは WP_Rewrite
   の処理にもかかわってくるので、非常に難しいです。
 * いっそのこと、デフォルトのパーマリンク (?author=3&cat=1 の型式をそのまま使う)
   で試してみるとどうでしょう? これだと URL 書き換えが発生しないので、確実に絞り込み
   ができます。ただし、URL がかっこわるくなるという欠点が出ます 😉
 *  トピック投稿者 [under](https://ja.wordpress.org/support/users/under/)
 * (@under)
 * [18年、 7ヶ月前](https://ja.wordpress.org/support/topic/%e6%8a%95%e7%a8%bf%e8%80%85author%e5%88%a5%e3%81%ab%e3%83%9a%e3%83%bc%e3%82%b8%e3%83%87%e3%82%b6%e3%82%a4%e3%83%b3%e3%82%92%e5%a4%89%e3%81%88%e3%82%8b%e3%81%ab%e3%81%af%ef%bc%9f/#post-110380)
 * そうなんですね、
    内部処理のところは私には手も足も出ないかと、、。
 * こちらの環境の場合、前述のとおり
    example.com//contents/author1/category-a/ は
   掲載コンテンツ自体は表示されていますが、 is_author()が効かず デフォルトの表示
   形式で吐き出されている状況です。
 * パーマリンク設定を変えずに
    example.com/contents/?author=3&cat=1 とURLを直接たたく
   と 最初に example.com/contents/category/category-a/?author=3 へリダイレクトさ
   れ、このURLから example.com/contents/author/author3/ へリダイレクトされている
   ようです。
 * ちなみに使用しているバージョンはWordpress 2.3.3です。
 * ご提案いただいた方法で、パーマリンク構造を
    `example.com/contents/%author%/%category%/%
   postname%/` からデフォルトに戻して試してみたところ、 おっしゃる通りリダイレクト
   はまったくしなくなったのですが、
 * ・header.php内に記述しているテンプレート側の振り分け判別is_author()の値(半角英字
   のユーザー名で指定しています）をまったく変えない場合
    `<?php elseif ( is_author('
   3')): ?>` ・header.php内に記述しているテンプレート側の振り分け判別値指定をid（
   数字のユーザID）で指定した場合 `<?php elseif ( is_author('author1')): ?>`
 * それぞれパーマリンク変更前と変わらず is_author()が効きませんでした。。
    デフォルト
   のパーマリンク設定であれば普通は振り分けが効くものなのでしょうか？？ うーんむずかしい。。
   SEO的なところも含めパーマリンク構造、できればカスタムで指定したいと考えています。
 *  トピック投稿者 [under](https://ja.wordpress.org/support/users/under/)
 * (@under)
 * [18年、 7ヶ月前](https://ja.wordpress.org/support/topic/%e6%8a%95%e7%a8%bf%e8%80%85author%e5%88%a5%e3%81%ab%e3%83%9a%e3%83%bc%e3%82%b8%e3%83%87%e3%82%b6%e3%82%a4%e3%83%b3%e3%82%92%e5%a4%89%e3%81%88%e3%82%8b%e3%81%ab%e3%81%af%ef%bc%9f/#post-110394)
 * もう少し検証してみましたので記載させていただきます。
 * example.com/contents/author1/category-a/
    振り分け効かず。
 * example.com/contents/author/author1/
    振り分けが効く。 このURLにカテゴリ判別?
   cat=をつけて example.com/contents/author/author1/?cat=1 にアクセスすると example.
   com/contents/category/category-a/ にリダイレクトがかかる。なぜかauthor情報がURL
   から抜けてしまう。 このURLに投稿者判別?author=をつけて example.com/contents/category/
   category-a/?author=3 にアクセスすると example.com/contents/author/author1/ に
   リダイレクトされ、category情報がURLから抜けてしまう。 author判別での表示振り分け
   は効いているがcategory別に投稿記事を表示できない。
 * 「特定の投稿者」が投稿した「特定のカテゴリ」のみを一覧で表示することは
    example.
   com/contents/author1/category-a/ のURLでできているが、その際 is_author()、is_category()
   判別による表示デザインの振り分け を両立させることができずデフォルトのデザイン
   の状態で表示されてしまう。
 * is_author判別が効くURL
    example.com/contents/author/author1/ example.com/contents/?
   author=1
 * 効かないURL
    example.com/contents/?author=1&cat=2 example.com/contents/author1/
   category-a/
 * どうもカテゴリと投稿者両方の判別を受けた場合、カテゴリ判別しか効いていないよう
   です。
    こちら両方受けて表示判別するのは仕様上できないということでしょうかね。。。？
 *  [Yuriko IKEDA](https://ja.wordpress.org/support/users/lilyfan/)
 * (@lilyfan)
 * [18年、 7ヶ月前](https://ja.wordpress.org/support/topic/%e6%8a%95%e7%a8%bf%e8%80%85author%e5%88%a5%e3%81%ab%e3%83%9a%e3%83%bc%e3%82%b8%e3%83%87%e3%82%b6%e3%82%a4%e3%83%b3%e3%82%92%e5%a4%89%e3%81%88%e3%82%8b%e3%81%ab%e3%81%af%ef%bc%9f/#post-110395)
 * ありゃりゃ。デフォルトのパーマリンクでも is_category() と is_author() の両立が
   無理でしたか……。
 * get_the_author_ID() で、現在の author ID が取れますので、こちらで振り分けすると
   どうでしょう? カテゴリーは in_category($category) を使ってみるとどうでしょう。
 *  [atsushigtr](https://ja.wordpress.org/support/users/atsushigtr/)
 * (@atsushigtr)
 * [18年、 7ヶ月前](https://ja.wordpress.org/support/topic/%e6%8a%95%e7%a8%bf%e8%80%85author%e5%88%a5%e3%81%ab%e3%83%9a%e3%83%bc%e3%82%b8%e3%83%87%e3%82%b6%e3%82%a4%e3%83%b3%e3%82%92%e5%a4%89%e3%81%88%e3%82%8b%e3%81%ab%e3%81%af%ef%bc%9f/#post-110396)
 *  [atsushigtr](https://ja.wordpress.org/support/users/atsushigtr/)
 * (@atsushigtr)
 * [18年、 7ヶ月前](https://ja.wordpress.org/support/topic/%e6%8a%95%e7%a8%bf%e8%80%85author%e5%88%a5%e3%81%ab%e3%83%9a%e3%83%bc%e3%82%b8%e3%83%87%e3%82%b6%e3%82%a4%e3%83%b3%e3%82%92%e5%a4%89%e3%81%88%e3%82%8b%e3%81%ab%e3%81%af%ef%bc%9f/#post-110397)
 * （勘違いがあったので、削除させていただきました）
 *  トピック投稿者 [under](https://ja.wordpress.org/support/users/under/)
 * (@under)
 * [18年、 7ヶ月前](https://ja.wordpress.org/support/topic/%e6%8a%95%e7%a8%bf%e8%80%85author%e5%88%a5%e3%81%ab%e3%83%9a%e3%83%bc%e3%82%b8%e3%83%87%e3%82%b6%e3%82%a4%e3%83%b3%e3%82%92%e5%a4%89%e3%81%88%e3%82%8b%e3%81%ab%e3%81%af%ef%bc%9f/#post-110402)
 * in_categoryを使用して
 *     ```
       <?php if ( is_author('author1')): ?>
       <?php if ( in_category('category-a')): ?>
       author1designheader
       <?php endif; ?>
       <?php endif; ?>
       ```
   
 * のような重複判別は一度ためしたのですが
    こちらも両立できないようでした。
 * 教えていただいたget_the_author_ID()、恥をさらすようで気が引けますが、、、。
 * 例えば
 *     ```
       <?php if ( is_author(get_the_author_ID())): ?>
       author1designheader
       <?php elseif ( is_author(get_the_author_ID())): ?>
       author2designheader
       <?php else : ?>
       author3designheader
       <?php endif; ?>
       ```
   
 * とか
 *     ```
       <?php if ( get_the_author_ID()): ?>
       author1designheader
       <?php elseif ( get_the_author_ID()): ?>
       author2designheader
       <?php else : ?>
       author3designheader
       <?php endif; ?>
       ```
   
 * とか
 *     ```
       <?php if ( get_the_author_ID('author1')): ?>
       author1designheader
       <?php elseif ( get_the_author_ID('author2')): ?>
       author2designheader
       <?php else : ?>
       author3designheader
       <?php endif; ?>
       ```
   
 * などググりながら色々試してみたんですが、どうもうまく動かなく、、
    get_the_author_ID
   は判別で使うまえに $author=get_the_author_ID()みたいに定義つけが必要なのでしょう
   か？
 * AtsushiGTRさん
    ありがとうございます。削除されたようですが 瞬間的にリンク先から
   ダウンロードして試させてもらいました。 user themesはアクセスしてきたユーザーに対して
   の判別のようですね。 惜しかったです。。。
 *  [Yuriko IKEDA](https://ja.wordpress.org/support/users/lilyfan/)
 * (@lilyfan)
 * [18年、 7ヶ月前](https://ja.wordpress.org/support/topic/%e6%8a%95%e7%a8%bf%e8%80%85author%e5%88%a5%e3%81%ab%e3%83%9a%e3%83%bc%e3%82%b8%e3%83%87%e3%82%b6%e3%82%a4%e3%83%b3%e3%82%92%e5%a4%89%e3%81%88%e3%82%8b%e3%81%ab%e3%81%af%ef%bc%9f/#post-110403)
 * get_the_author_ID() は、絞り込まれた執筆者のID番号を返す関数です。なので、振り分け
   は以下のような感じにします。
 *     ```
       <?php switch (get_the_author_ID()) {
       case 1:
           (author 1 向けのテンプレート)
           break;
       case 2:
           (author 2 向けのテンプレート)
           break;
       default:
           (その他の author 向けテンプレート)
           break;
       } ?>
       ```
   
 * 関数名から「ID 番号が得られる」ことは自明だと思って説明しませんでしたが、is_author()
   のように TRUE/FALSE を返すものだと勘違いされていたようですね……。
 * ID 番号じゃなくて nicename を使うならば get_the_author_nicename() など別のテンプレート
   タグがありますので、author-template.php を覗いてみてください (けっきょくはソース
   が最良のリファレンス 😉
 *  トピック投稿者 [under](https://ja.wordpress.org/support/users/under/)
 * (@under)
 * [18年、 7ヶ月前](https://ja.wordpress.org/support/topic/%e6%8a%95%e7%a8%bf%e8%80%85author%e5%88%a5%e3%81%ab%e3%83%9a%e3%83%bc%e3%82%b8%e3%83%87%e3%82%b6%e3%82%a4%e3%83%b3%e3%82%92%e5%a4%89%e3%81%88%e3%82%8b%e3%81%ab%e3%81%af%ef%bc%9f/#post-110406)
 * ありがとうございます！
    教えていただいた方法から少しいじって無事表示の 振り分け
   ができるようになりました。 正直なぜこの構文で振り分けができているのかいまいち
   わからないんですが、
 * なぜか`<?php switch (get_the_author_ID()) {`
    だとうまく振り分けができなく（僕
   の使い方が良くなかったのかもしれません。。）
 * 他に投稿者を呼び出せそうなものを一通り試したところ
    `<?php switch ($author) {`
   この形でauthor判別を受けるようになりました。 カテゴリの絞り込みも両立している
   ようです。
 * ちなみにget_the_author_ID()って投稿者ID（数字のID)を返すんですよね。。？
    翻訳
   しながらauthor-template色々眺めたんですが、もしかしたらループ内でしか 使えない
   のかなと思い$authorで試した感じです。 （ちなみに条件分岐はheader.php内のみでおこ
   なっています）
 * get_the_author_ID()イコール$authorだと認識しているんですが
    これは勘違いなのかな。
   結局使い方がわかっていない自分。。
 * lilyfanさん助かりました〜。:-)
 *  [Yuriko IKEDA](https://ja.wordpress.org/support/users/lilyfan/)
 * (@lilyfan)
 * [18年、 7ヶ月前](https://ja.wordpress.org/support/topic/%e6%8a%95%e7%a8%bf%e8%80%85author%e5%88%a5%e3%81%ab%e3%83%9a%e3%83%bc%e3%82%b8%e3%83%87%e3%82%b6%e3%82%a4%e3%83%b3%e3%82%92%e5%a4%89%e3%81%88%e3%82%8b%e3%81%ab%e3%81%af%ef%bc%9f/#post-110524)
 * ちょっと返事が遅くなりました。` get_the_author_ID()` はお察しの通りループの中
   で使うものでした (それぞれの記事の投稿者を示す)。`$author` はクエリー条件として
   の投稿者だと思われます。
 * なので、author でクエリーを投げた場合は、実質的には get_the_author_ID() == $author
   となるはずです。複数の author に一致するようなクエリーの場合は違ってきます。
 * とりあえず動いているようで何よりです。

12件の返信を表示中 - 1 - 12件目 (全12件中)

 トピック「投稿者(author)別にページデザインを変えるには？」には新たに返信すること
はできません。

## タグ

 * [author](https://ja.wordpress.org/support/topic-tag/author/)
 * [テンプレート](https://ja.wordpress.org/support/topic-tag/%e3%83%86%e3%83%b3%e3%83%97%e3%83%ac%e3%83%bc%e3%83%88/)
 * [デザイン変更](https://ja.wordpress.org/support/topic-tag/%e3%83%87%e3%82%b6%e3%82%a4%e3%83%b3%e5%a4%89%e6%9b%b4/)
 * [example.com](https://ja.wordpress.org/support/topic-tag/example-com/)
 * [URLでの判別](https://ja.wordpress.org/support/topic-tag/url%e3%81%a7%e3%81%ae%e5%88%a4%e5%88%a5/)
 * [投稿者別](https://ja.wordpress.org/support/topic-tag/%e6%8a%95%e7%a8%bf%e8%80%85%e5%88%a5/)

 * フォーラム: [使い方全般](https://ja.wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 12件の返信
 * 3人の参加者
 * 最後の返信者: [Yuriko IKEDA](https://ja.wordpress.org/support/users/lilyfan/)
 * 最後の活動: [18年、 7ヶ月前](https://ja.wordpress.org/support/topic/%e6%8a%95%e7%a8%bf%e8%80%85author%e5%88%a5%e3%81%ab%e3%83%9a%e3%83%bc%e3%82%b8%e3%83%87%e3%82%b6%e3%82%a4%e3%83%b3%e3%82%92%e5%a4%89%e3%81%88%e3%82%8b%e3%81%ab%e3%81%af%ef%bc%9f/#post-110524)
 * 状態: 解決済

## トピック

### 人気のトピック

### 返信がないトピック

### サポート関連ではないトピック

### 解決済みのトピック

### 未解決のトピック

### すべてのトピック
