Advertisement
Guest User

Untitled

a guest
Apr 29th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.09 KB | None | 0 0
  1. ※ページの条件を指定※
  2.  
  3. is_○○○()の部分を変更
  4.  
  5. // TOPページ
  6. is_home()
  7.  
  8. // 投稿(single)ページ
  9. is_single()
  10.  
  11. // 固定ページ
  12. is_page()
  13. ※複数指定
  14. (is_page(array('●','●','●')))
  15.  
  16. // アーカイブページ
  17. is_archive()
  18.  
  19. // カスタム投稿タイプアーカイブページ カスタム投稿タイプを入れてください
  20. is_post_type_archive( 'post_type' )
  21.  
  22. // 日付アーカイブページ
  23. is_date()
  24.  
  25. // 年別アーカイブページ
  26. is_year()
  27.  
  28. // 月別アーカイブページ
  29. is_month()
  30.  
  31. // 制作者アーカイブページ
  32. is_author()
  33.  
  34. // カテゴリーページ
  35. is_category()
  36.  
  37. // カテゴリーページ 配列での指定(カテゴリID3,カテゴリスラッグfoo,カテゴリ名Bar barのいずれか)
  38. is_category( array(3,'foo','Bar bar') )
  39.  
  40. // タグページ
  41. is_tag()
  42.  
  43. // 特定のpost typeで判別
  44. if( is_singular( '●●●' ) ) {
  45. // 投稿タイプが●●●のシングルページ
  46. }
  47.  
  48. // いずれかのpost typeで判別
  49. if( is_singular( array( '●●●', '▲▲▲', '■■■' ) ) ) {
  50. /* 投稿タイプが
  51. * '●●●', '▲▲▲', '■■■'
  52. * いずれかに一致するシングルページ
  53. */
  54. )
  55.  
  56. // タクソノミーページ
  57. is_tax()
  58.  
  59. // タクソノミーページ ■■■というスラッグのタクソノミーアーカイブが表示された時
  60. is_tax( '■■■' )
  61.  
  62. // タクソノミーページ bar1,bar2のスラッグがfooタクソノミーアーカイブで表示された時
  63. is_tax( 'foo', array('bar1','bar2') )
  64. ↑これ使える、カスタムタクソノミー(親カテ)に属するターム(子カテ)だけを対象とする記述ができる
  65.  
  66. //カスタム投稿タイプ利用時のタクソノミー条件
  67. is_object_in_term($post->ID, '●●●','▲▲▲') ●●●=タクソノミー、▲▲▲=ターム
  68.  
  69. // 検索結果ページ
  70. is_search()
  71.  
  72. // フィードページ
  73. is_feed()
  74.  
  75. // 404ページ
  76. is_404()
  77.  
  78. //ページテンプレート (特定のページテンプレートを使っているかどうかをチェックできる)
  79. is_page_template('●●●.php')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement