<?php //wp_get_archives('type=monthly'); ?>
type=monthlyで年月がでるなら
type=listとかなんとかできないないものか。
探したら、Main_PageのDesign and Layoutの
Template TagsのGeneral tagsに、wp_get_archives()の説明があった。
- 12ヶ月を表示するなら、
<p><?php wp_get_archives('type=monthly&limit=12'); ?></p> - 15日表示するなら、
<p><?php wp_get_archives('type=daily&limit=15'); ?></p> - 最後の投稿20個なら
<p><?php wp_get_archives('type=postbypost&limit=20&format=custom'); ?></p> - ドロップダウンボックスは
<select name="archive-dropdown" onChange='document.location.href=this.options[this.selectedIndex].value;'>
<option value=""><?php echo attribute_escape(__('Select Month')); ?></option>
<?php wp_get_archives('type=monthly&format=option&show_post_count=1'); ?> </select>
と書いてある。
それぞれを、
<?php //wp_get_archives('type=monthly'); ?>
と入れ替えてみるとしっかり動く。
ということは、全部の記事をドロッブダウンさせるには、
<select name="archive-dropdown" onChange='document.location.href=this.options[this.selectedIndex].value;'>
<option value=""><?php echo attribute_escape(__('Select Month')); ?></option>
<?php wp_get_archives('type=postbypost&format=custom'); ?>
</select>
でいけるかも。
さっそくsidebar.phpの
<?php //wp_get_archives('type=monthly'); ?>
の場所に入れてみる。

<?php //wp_get_archives('type=postbypost&limit=20&format=custom'); ?>
<select name="archive_option" onChange='document.location.href=this.options[this.selectedIndex].value;'>
<option>Archives</option>
<?php wp_get_archives("format=option&type=postbypost"); ?>
</select>
こういう選択場所が現れた。

wp_get_archives2.png
ここで選ぶとそのページが表示される。
ごきげん!

0 件のコメント:
コメントを投稿