Title: 複数の投稿タイプ（カスタム含）をまとめた年別アーカイブの作り方を教えてください
Last modified: 2017年7月31日

---

# 複数の投稿タイプ（カスタム含）をまとめた年別アーカイブの作り方を教えてください

 *  [ieyasu](https://ja.wordpress.org/support/users/ieyasu/)
 * (@ieyasu)
 * [9年、 2ヶ月前](https://ja.wordpress.org/support/topic/%e8%a4%87%e6%95%b0%e3%81%ae%e6%8a%95%e7%a8%bf%e3%82%bf%e3%82%a4%e3%83%97%ef%bc%88%e3%82%ab%e3%82%b9%e3%82%bf%e3%83%a0%e5%90%ab%ef%bc%89%e3%82%92%e3%81%be%e3%81%a8%e3%82%81%e3%81%9f%e5%b9%b4%e5%88%a5/)
 * 現在、wordpressを触りながら勉強しています。
    記事の内容によってカスタム投稿で
   雛形を分けながら、 一方で記事一覧ページには複数の投稿タイプをまとめて表示できる
   ようにし、 同ページにはタイトルだけでなく、wp_get_archives を使って年別アーカイブ
   も 表示できるようにしました。【下記が該当ソースです】 　<?php 　　wp_get_archives(
   array( 　　’post_type’ => array(‘post’,’post111′,’post222′), 　　’type’ => ‘yearly’,’
   show_post_count’ => 0 　　)); 　?>
 * しかし、よく見ると年別アーカイブに表示されていない年があり、
    いろんなページを
   調べた結果、上記の記述では複数の投稿タイプではなく、デフォルトの ‘post’ の 年
   別アーカイブしか表示されないところまで辿り着くことができました。 ただ、ここから
   どうやってカスタム投稿タイプを含む複数の投稿タイプの混合年別アーカイブを 表示
   できるように記述していいのか、全く分からなくなってしまいました。
 * できればサンプルソースをいただければ幸いですが、何かヒントでも構いません。
    どなた
   かお力を貸していただければと思います。よろしくお願いします

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

 *  [CG](https://ja.wordpress.org/support/users/du-bist-der-lenz/)
 * (@du-bist-der-lenz)
 * [9年、 2ヶ月前](https://ja.wordpress.org/support/topic/%e8%a4%87%e6%95%b0%e3%81%ae%e6%8a%95%e7%a8%bf%e3%82%bf%e3%82%a4%e3%83%97%ef%bc%88%e3%82%ab%e3%82%b9%e3%82%bf%e3%83%a0%e5%90%ab%ef%bc%89%e3%82%92%e3%81%be%e3%81%a8%e3%82%81%e3%81%9f%e5%b9%b4%e5%88%a5/#post-219586)
 * 複数の投稿タイプを対象にするとなると、`'post_type' => array('post','page','$post_custom'),`
   になりませんか。
 *  トピック投稿者 [ieyasu](https://ja.wordpress.org/support/users/ieyasu/)
 * (@ieyasu)
 * [9年、 2ヶ月前](https://ja.wordpress.org/support/topic/%e8%a4%87%e6%95%b0%e3%81%ae%e6%8a%95%e7%a8%bf%e3%82%bf%e3%82%a4%e3%83%97%ef%bc%88%e3%82%ab%e3%82%b9%e3%82%bf%e3%83%a0%e5%90%ab%ef%bc%89%e3%82%92%e3%81%be%e3%81%a8%e3%82%81%e3%81%9f%e5%b9%b4%e5%88%a5/#post-219588)
 * ご意見ありがとうございます。
 * <?php
    　　wp_get_archives(array( 　　’post_type’ => array(‘post’,’page’,’$post_custom’),’
   type’ => ‘yearly’, 　　’show_post_count’ => 0 　　)); 　?>
 * で試してみましたが、ダメでした。。
 *  [gblsm](https://ja.wordpress.org/support/users/gblsm/)
 * (@gblsm)
 * [9年、 2ヶ月前](https://ja.wordpress.org/support/topic/%e8%a4%87%e6%95%b0%e3%81%ae%e6%8a%95%e7%a8%bf%e3%82%bf%e3%82%a4%e3%83%97%ef%bc%88%e3%82%ab%e3%82%b9%e3%82%bf%e3%83%a0%e5%90%ab%ef%bc%89%e3%82%92%e3%81%be%e3%81%a8%e3%82%81%e3%81%9f%e5%b9%b4%e5%88%a5/#post-219589)
 * 下記の記事が参考になるかもしれません。
 * WPの月別アーカイブを複数のカスタム投稿が混在した形で表示したい
    [https://teratail.com/questions/67797](https://teratail.com/questions/67797)
 *  トピック投稿者 [ieyasu](https://ja.wordpress.org/support/users/ieyasu/)
 * (@ieyasu)
 * [9年、 2ヶ月前](https://ja.wordpress.org/support/topic/%e8%a4%87%e6%95%b0%e3%81%ae%e6%8a%95%e7%a8%bf%e3%82%bf%e3%82%a4%e3%83%97%ef%bc%88%e3%82%ab%e3%82%b9%e3%82%bf%e3%83%a0%e5%90%ab%ef%bc%89%e3%82%92%e3%81%be%e3%81%a8%e3%82%81%e3%81%9f%e5%b9%b4%e5%88%a5/#post-219597)
 * ご意見ありがとうございます。
    コチラのページ拝見しましたが、、、少し内容のレベル
   が高く、、、 functions.php と page-xxx.php の双方に記述が必要ということでいい
   のでしょうか。 どの部分を変更するのかも含め、もう少しだけ噛み砕いて説明していただける
   ページは ご存知でしょうか。
 *  トピック投稿者 [ieyasu](https://ja.wordpress.org/support/users/ieyasu/)
 * (@ieyasu)
 * [9年、 2ヶ月前](https://ja.wordpress.org/support/topic/%e8%a4%87%e6%95%b0%e3%81%ae%e6%8a%95%e7%a8%bf%e3%82%bf%e3%82%a4%e3%83%97%ef%bc%88%e3%82%ab%e3%82%b9%e3%82%bf%e3%83%a0%e5%90%ab%ef%bc%89%e3%82%92%e3%81%be%e3%81%a8%e3%82%81%e3%81%9f%e5%b9%b4%e5%88%a5/#post-219613)
 * 連続でスイマセン。
    先ほどこちらのページを見つけて、ソースを試してみたところ、、、
   [http://hirashimatakumi.com/blog/3962.html](http://hirashimatakumi.com/blog/3962.html)—-
   <?php // 年別アーカイブリストを表示 　　$year=NULL; // 年の初期化 　　$args =
   array( // クエリの作成 　　’post_type’ => array(‘post’,’post222222′), // 投稿
   タイプの指定 　　’orderby’ => ‘date’, // 日付順で表示 　　’posts_per_page’ =>-
   1 // すべての投稿を表示 　　　); 　　$the_query = new WP_Query($args); if($the_query-
   >have_posts()){ // 投稿があれば表示 　　echo ‘<ul class=”year-list”>’; 　　while(
   $the_query->have_posts()): $the_query->the_post(); // ループの開始 　　if ($year!
   = get_the_date(‘Y’)){ // 同じ年でなければ表示 　　$year = get_the_date(‘Y’); //
   年の取得 　　echo ’
    - [‘.$year.’](https://ja.wordpress.org/support/topic/%E8%A4%87%E6%95%B0%E3%81%AE%E6%8A%95%E7%A8%BF%E3%82%BF%E3%82%A4%E3%83%97%EF%BC%88%E3%82%AB%E3%82%B9%E3%82%BF%E3%83%A0%E5%90%AB%EF%BC%89%E3%82%92%E3%81%BE%E3%81%A8%E3%82%81%E3%81%9F%E5%B9%B4%E5%88%A5/'.home_url( '/', 'http' ).'date/'.$year.'?output_format=md)
    - ‘; // 年別アーカイブリストの表示
       　　} 　　endwhile; // ループの終了 　　
      echo ‘‘; 　　wp_reset_postdata(); // クエリのリセット 　　} 　?> —- カスタム
      投稿も普通の投稿もマージされた年別アーカイブが表示されました。 ただ、今度は
      リンク部分にカスタムが必要なのか、年別からのアーカイブが404エラーになってしま
      います。 このソースでの修正方法（または別の方法の提示）でも構いません。 教え
      ていただければと思います。宜しくお願いいたします。
 *  -  この返信は9年、 2ヶ月前に[ieyasu](https://ja.wordpress.org/support/users/ieyasu/)
      が編集しました。

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

 トピック「複数の投稿タイプ（カスタム含）をまとめた年別アーカイブの作り方を教えて
ください」には新たに返信することはできません。

## タグ

 * [カスタム投稿](https://ja.wordpress.org/support/topic-tag/%e3%82%ab%e3%82%b9%e3%82%bf%e3%83%a0%e6%8a%95%e7%a8%bf/)
 * [wp_get_archives](https://ja.wordpress.org/support/topic-tag/wp_get_archives/)
 * [年別アーカイブ](https://ja.wordpress.org/support/topic-tag/%e5%b9%b4%e5%88%a5%e3%82%a2%e3%83%bc%e3%82%ab%e3%82%a4%e3%83%96/)

 * フォーラム: [バグ報告と提案](https://ja.wordpress.org/support/forum/feedback/)
 * 5件の返信
 * 3人の参加者
 * 最後の返信者: [ieyasu](https://ja.wordpress.org/support/users/ieyasu/)
 * 最後の活動: [9年、 2ヶ月前](https://ja.wordpress.org/support/topic/%e8%a4%87%e6%95%b0%e3%81%ae%e6%8a%95%e7%a8%bf%e3%82%bf%e3%82%a4%e3%83%97%ef%bc%88%e3%82%ab%e3%82%b9%e3%82%bf%e3%83%a0%e5%90%ab%ef%bc%89%e3%82%92%e3%81%be%e3%81%a8%e3%82%81%e3%81%9f%e5%b9%b4%e5%88%a5/#post-219613)
 * 状態: 未解決

## トピック

### 人気のトピック

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

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

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

### 未解決のトピック

### すべてのトピック
