wp_get_archives – WordPress テンプレートタグのリファレンス

この関数は、日付ベースのアーカイブリストを表示します。テンプレートの中にどこでもこのタグを使用することができます。

原文(翻訳元):This function displays a date-based archives list. This tag can be used anywhere within a template.

のテンプレートタグ使用方法

<?php wp_get_archives( $args ); ?>

デフォルトの使い方

<?php $args = array(
    'type'            => 'monthly',
    'limit'           => ,
    'format'          => 'html',
    'before'          => ,
    'after'           => ,
    'show_post_count' => false,
    'echo'            => 1 ); ?>

デフォルトでは、使用を示します:

  • 毎月のアーカイブリンクを表示します
  • すべてのアーカイブ(数では、制限されない)を表示します。
  • <li>HTMLリストの中のアーカイブを表示します。
  • 各リンクの前後に何も表示されません
  • どんな表示にもポストの数のカウントをしません。

原文(翻訳元)By default, the usage shows:

* Monthly archives links displayed
* Displays all archives (not limited in number)
* Displays archives in an <li> HTML list
* Nothing displayed before or after each link
* Does not display the count of the number of posts

wp_get_archivesのパラメーター

type

(string) アーカイブリストを表示するためのタイプです。デフォルトはWordPressの設定です。 有効値:

  • yearly
  • monthly – Default
  • daily
  • weekly
  • postbypost (投稿は投稿日順)
  • alpha (same as postbypost but posts are ordered by post title)

原文(翻訳元)(string) The type of archive list to display. Defaults to WordPress settings. Valid values:

* yearly
* monthly – Default
* daily
* weekly
* postbypost (posts ordered by post date)
* alpha (same as postbypost but posts are ordered by post title)

limit

(integer)アーカイブの数を取得する。デフォルトでは制限はありません。

原文(翻訳元) (integer) Number of archives to get. Default is no limit.

format

(string) アーカイブのリストの形式です。有効な値:

  • html – HTMLリストタグの前後の文字列です。これがデフォルトです。
  • option – セレクト(<select>) かドロップダウン(<option>)のタグのオプションです。
  • link – リンク(<link>)タグの中で。
  • custom – カスタムリストを使用する前と文字列の後。

原文(翻訳元)(string) Format for the archive list. Valid values:

* html – In HTML list (<li>) tags and before and after strings. This is the default.
* option – In select (<select>) or dropdown option (<option>) tags.
* link – Within link (<link>) tags.
* custom – Custom list using the before and after strings.

before

(string)HTMLまたはフォーマットオプションのカスタムを使用する時にリンクの前にテキストリンクを配置します。デフォルトはありません。

原文(翻訳元)(string) Text to place before the link when using the html or custom for format option. There is no default.

after

(string)HTMLまたはフォーマットオプションのカスタムを使用する時にリンクの後にテキストリンクを配置します。デフォルトはありません。

原文(翻訳元)(string) Text to place after the link when using the html or custom for format option. There is no default.

show_post_count

アーカイブ内の記事の数を表示しないでください。’postbypost’を除いたすべてのタイプで使用してください。

  • 1 (True)
  • 0 (False) – Default

原文(翻訳元)(boolean) Display number of posts in an archive or do not. For use with all type except ‘postbypost’.

* 1 (True)
* 0 (False) – Default

echo

(boolean) 出力、またはそれを返して表示します。

  • 1 (True) – Default
  • 0 (False)

原文(翻訳元)(boolean) Display the output or return it.

* 1 (True) – Default
* 0 (False)

過去12ヶ月

月別アーカイブリストを表示し、最後の12月のみ表示します。

原文(翻訳元)Displays archive list by month, displaying only the last twelve.

<?php wp_get_archives('type=monthly&limit=12'); ?>

最後の15日

日別にアーカイブリストを表示し、最後の15日間のみ表示します。

原文(翻訳元)Displays archive list by date, displaying only the last fifteen days.

<?php wp_get_archives('type=daily&limit=15'); ?>

最後の20投稿

最後の20最新記事を記事タイトルによってリスト化したアーカイブリストを表示します。

原文(翻訳元)Displays archive list of the last twenty most recent posts listed by post title.

<?php wp_get_archives('type=postbypost&limit=20&format=custom'); ?>

ドロップダウンボックス

毎月のアーカイブをセレクトタグで記事数を表示した、ドロップダウンボックスを表示します。

原文(翻訳元)Displays a dropdown box of Monthly archives, in select tags, with the post count displayed.

<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>

全ての記事をアルファベット順で表示する方法

特にサイトマップのような昨日をアーカイブにしたい場合に、すべて表示投稿アルファベット順に表示します。

原文(翻訳元)Displays ALL posts alphabetically, especially if you want to have an archive that serves like a sitemap.

<?php wp_get_archives('type=alpha'); ?>

変更ログ

Since: 1.2.0

ソースファイル

wp_get_archives()は、wp-includes/general-template.php内に位置しています。

原文(翻訳元)wp_get_archives() is located in wp-includes/general-template.php.

関連テンプレートタグ

wp_list_authors, wp_list_categories, wp_list_pages, wp_list_bookmarks, wp_list_comments, wp_get_archives, wp_page_menu, wp_dropdown_pages, wp_dropdown_categories, wp_dropdown_users

Tags:

Page 1 of 0