wp_get_archivesを使って年別リストを出力する。
テキストの最後に「年」をいれたり、セレクトボックス型のナビゲーションでも使えるようにformatも指定できるようにする。
formatは表示形式を指定できるので、「html・link・option」などを指定します。
functions.phpに追加
/**
 * 年リスト出力
 */
function theYearList($taxsonomy, $format = 'html'){
    $year_list = wp_get_archives(array(
        'type' => 'yearly',
        'format' => $format,
        'post_type' => $taxsonomy,
        'show_post_count' => false,
        'echo' => 0
    ));
    // 生成コードに対してstr_replaceで年をつける
    if($format == 'html'){
        $year_list = str_replace("</a>", "年</a>", $year_list);
    }
    else if($format == 'option'){
        $year_list = str_replace(" </option>", "年</option>", $year_list);
    }
    echo $year_list;
}
閉じタグを置換処理で「年」をつけたり、「2014(13)」みたいな括弧に件数入れたりもできます。
テンプレートでの使い方
<h1>年別アーカイブ(リスト形式)</h1>
<ul>
    <?php theYearList('news'); ?>
</ul>
<h1>年別アーカイブ(セレクトフォーム形式)</h1>
<form>
    <select>
        <option>年を選択</option>
        <?php theYearList('news', 'option'); ?>
    </select>
</form>
 
      

 
     
     
    