Wordpressの条件によるページ制御法

Wordpressのテンプレートを改造しているとき、トップページの場合や個別記事の場合で表示内容を変えたいことがあります。

そんな時

トップページなら if (is_home() ) 以下同様

個別ページ is_single()

カテゴリ is_category() 
(引数にカテゴリIDを入れれば特定カテゴリの制御も可。 例 if(is_category(11) || is_category(12)) )

(投稿でなく)ページ is_page()

検索結果 is_search()

アーカイブ is_archive()

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.

© PHPress since 2008