Category belong to the same design as the individual article
Categories: Design
2010-08-25 Last update:
2008-03-18: Sun Posts
What should I do when an attempt is made to apply the same design as well as top category of the category page, · · · The design of the individual article.
If you do not know at all thinks it may be flat out on the page when I went to a separate page, check the appropriate category and in single.php? "Then What syntax" can understand.
Discover how to resolve the Bali forum was to give up.
Ten thousand years our forums! !
I tried something close, $ post = $ wp_query-> post; I did not know that. Have heard me resolve () in_category This template tags.
Following that procedure.
- Create a file called "single-6.php" and "single-base.php" to copy the "single.php". ※ The name that you may copy anything
- Delete all the contents by opening the "single.php". Enter and save the following script. Upload all the files
<?php
$post = $wp_query->post;
if(in_category('6')) {
include(TEMPLATEPATH . '/single-6.php');
} else {
include(TEMPLATEPATH . '/single-base.php');
}
?>
以上で、個別記事ページにもカテゴリー毎でのテンプレートが採用される。
あとはカテゴリトップ用の「category-xx.php」と個別記事用の「single-xx.php」のデザインを統一しておけば良い。
- タグ
- single.php , カテゴリ , デザイン , 分ける
- トラックバックURL





























2009/1/6 火曜日 12:43:56
いつも参考にさせていただいております。
初心者ゆえの質問になりますが、上記single.phpの
ソースですが、もし複数カテゴリがあり、複数の
個別ページを設定する場合は、同じような記述を
繰り返し記入すれば大丈夫でしょうか。
お恥ずかしい質問ですがご返答いただけると幸い
です。何卒よろしくお願い致します。
2009/1/6 火曜日 13:09:12
>カイカイ様
コメントありがとうございます。
ご質問の内容ですが、それで良いと思います。
if(in_category('6')) {
include(TEMPLATEPATH . '/single-6.php');
} elseif(in_category('9')) {
include(TEMPLATEPATH . '/single-9.php');
} else {
include(TEMPLATEPATH . '/single-base.php');
}
こんな感じになります。
2009/1/6 火曜日 15:34:47
早々にご回答いただき、誠にありがとうございました!!
おかげで希望通りのサイトができそうです!!
今後も参考にさせていただきますので、何卒よろし
くお願い致します。
2009/1/6 火曜日 15:49:43
>カイカイ様
お役に立てて何よりです。
仕事の片手間で気付いた事やハマった事などを書いているので更新頻度は遅いのですが、私と同じようにちょっとした事で悩んでいる方の役に立っていただけると嬉しいです。
今後とも宜しくお願い致します。
2010/12/25 土曜日 20:31:18
ずーっと悩んでいたことが、解決しました。
助かりました。感謝です。orz。最高のクリスマスプレゼントです。
2010/12/27 月曜日 09:21:12
>本当に感謝 さん
名前にするぐらいなので本当に感謝していただいてるのですね(笑)。
思わぬところでサンタになれたのでこちらも嬉しいです。