WordPressの個別記事ページをカテゴリ毎に違うものにしたかったので、分岐を書きました!!
<?php
if(in_category('information')){
include(TEMPLATEPATH . '/single-information.php');
}
elseif(in_category('event')){
include(TEMPLATEPATH . '/single-event.php');
}
elseif(in_category('blog')){
include(TEMPLATEPATH . '/single-blog.php');
}
else{
include(TEMPLATEPATH . '/single-defalut.php');
}
?>
全部、single-defalut.phpが読み込まれてる…
分岐できてないなんで…
.
.
.
こちらのサイトに行き着きました。
http://webryy.com/blog/archives/220
<?php $post = $wp_query->post; ?>
これがいるんだって。追加したらできたよ。
これなに?なんでいるの?
誰か教えて〜〜。
完成品
<?php
$post = $wp_query->post;
if(in_category('information')){
include(TEMPLATEPATH . '/single-information.php');
}
elseif(in_category('event')){
include(TEMPLATEPATH . '/single-event.php');
}
elseif(in_category('blog')){
include(TEMPLATEPATH . '/single-blog.php');
}
else{
include(TEMPLATEPATH . '/single-defalut.php');
}
?>