! 各ページ右上の画像広告経由でコンピュータウィルスがダウンロードされた可能性があります。ウィルスチェックをお願いします。詳しくは http://bono.s201.xrea.com/2008/06/693-virus_by_xrea_ad/ をご覧ください。ご迷惑をおかけしてしまい大変申し訳ありません。
テンプレートタグ/wp get archives
出典: ps*wiki
< テンプレートタグ
この関数 wp_get_archives() は、get_archives() と同じように日付ベースのアーカイブリストを表示します。違いは、パラメータの引数をクエリ文字列形式で関数に渡すことだけです。このタグはテンプレートのどこでも使えます。
<?php wp_get_archives('引数'); ?>
$defaults = array('type' => 'monthly', 'limit' => '', 'format' => 'html',
'before' => '', 'after' => '', 'show_post_count' => false);
デフォルトのままで使うと、次のとおり表示します。
- 月別アーカイブのリンクを表示
- 全アーカイブを表示(表示数の制限なし)
- <li> HTML(番号なし箇条書き)リストでアーカイブを表示
- 各リンクの前後に何も表示しない
- 投稿数を表示しない
<?php wp_get_archives(); ?>
この 12か月の月別アーカイブリストを表示します。
<ul>
<?php wp_get_archives('type=monthly&limit=12'); ?>
</ul>
この 15日の日別アーカイブリストを表示します。
<ul>
<?php wp_get_archives('type=daily&limit=15'); ?>
</ul>
最新 20件の投稿記事タイトルの一覧を表示します。
<ul>
<?php wp_get_archives('type=postbypost&limit=20&format=custom'); ?>
</ul>
月別アーカイブのドロップダウンボックス(ドロップダウンメニュー)を表示、各選択肢に投稿数を表示します。
<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>
- type
- (文字列) 表示するアーカイブリストの種類。初期値は月別アーカイブ。有効値:
-
yearly -
monthly(初期値) -
daily -
weekly -
postbypost
-
- limit
- (整数) 取得するアーカイブ数。初期値は制限なし。
- format
- (文字列) アーカイブリストの形式。有効値:
-
html(初期値) - HTML のリストタグ(<li>)と before・after の文字列。 -
option- セレクトボックスまたはドロップダウンメニュー用のセレクトタグ(<select>)内のオプションタグ(<option>)。 -
link- リンクタグ(<link>)内に。 -
custom- Custom list using the before・after の文字列を用いたカスタムリスト。
-
- before
- (文字列) Text to place before the link when using the html or custom for format option. There is no default.
- after
- (文字列) Text to place after the link when using tge html or custom for format option. There is no default.
- show_post_count
- (真偽値) Display number of posts in an archive (1 - true) or do not (0 - false). For use with all type except 'postbypost'. Defaults to 0.
bloginfo, bloginfo_rss, get_bloginfo, get_bloginfo_rss, wp_title, get_archives, wp_get_archives, get_calendar, get_posts, wp_list_pages, wp_dropdown_pages, wp_loginout, wp_register, query_posts, rss_enclosure
