(投稿)月別アーカイブ(過去の記事を月ごとにまとめたリスト)の表示
月別アーカイブの表示
<?php wp_get_archives('type=monthly&show_post_count=1&limit=12'); ?>
・type=monthly: 「月別」でアーカイブを作成します。
・show_post_count=1: その月に何件の記事があるか数字を表示します(例:20XX年10月 (5))。
・limit=12: 直近の12ヶ月分だけを表示します。
月別アーカイブの表示(ドロップダウン)
<select name="archive-dropdown" onChange='document.location.href=this.options[this.selectedIndex].value;'>
<option value=""><?php echo esc_attr(__('Select Month')); ?></option>
<?php wp_get_archives('type=monthly&format=option&show_post_count=1&limit=12'); ?>
</select>