- 赤色のリンクは、まだ日本語Codexに存在しないページ・画像です。英語版と併せてご覧ください。(詳細)
テンプレートタグ/the modified date
このページ「テンプレートタグ/the modified date」は未翻訳です。和訳や日本語情報を加筆してくださる協力者を求めています。
タグ一覧: テンプレートタグ | インクルードタグ | 条件分岐タグ | その他の関数 | Code Reference
使い方: テンプレートタグ入門 | パラメータの渡し方 | 初心者の方へ | その他のテーマ関連資料
目次
説明
このタグは記事を最後に更新した日付 (または時間) を表示します。the_modified_time() と似ていますが、このタグでは最後に更新した日付または時間を表示します。このタグはループ内で使用しなければなりません。パラメータが指定されない場合、管理画面 > 設定 > 一般設定 にある日付フォーマットの設定が適用されます。
記事やページを更新していない場合、更新日は作成日と同じになります。
値を取得するには、 get_the_modified_date() をお使いください。
使い方
<?php the_modified_date( $d, $before, $after, $echo ); ?>
パラメータ
- $d
- (文字列) (オプション) 表示する日付フォーマット。デフォルトでは管理画面で設定した値が適用されます。日付と時刻の書式 を参照してください。
- $before
- (文字列) (オプション) 日付の前に出力
- 初期値: なし
- $after
- (文字列) (オプション) 日付の後ろに出力
- 初期値: なし
- $echo
- (真または偽) (オプション) デフォルトは表示をします。日付をエコーまたはそれを返すかどうか。
- 初期値: true
- true (デフォルト)
- false
用例
初期設定での使用
管理画面 > 設定 > 一般設定 の日付フォーマットの設定 (例: F j, Y) を使って最終更新日を表示します。
<p>最終更新日: <?php the_modified_date(); ?></p>
「月 日, 年」の順で表示
「F j, Y」という日付フォーマットで最終更新日を表示します (例: 12 月 2, 2006)。
<p>最終更新日: <?php the_modified_date('F j, Y'); ?></p>
日付と時刻
日付と時刻を表示します。
<p>更新日時: <?php the_modified_date('F j, Y'); ?> at <?php the_modified_date('g:i a'); ?></p>
Date with superscript or subscript number suffixes
Displays the date with a superscript or subscript st, nd, rd or th after the day. Because characters from the alphabet are used to represent the date format types, each of the HTML tag characters need to be escaped using a back slash. Superscript HTML tag is <sup> and subscript is <sub>.
<p>Modified: <?php the_modified_date('j\<\s\u\p\>S\<\/\s\u\p\> M Y'); ?></p>
変更履歴
関連
日時に関連するタグ:
get_calendar(),
get_day_link(),
get_month_link(),
get_the_date(),
get_the_time(),
get_year_link(),
single_month_title(),
the_date(),
the_date_xml(),
the_modified_date(),
get_the_modified_date(),
the_modified_time(),
get_the_modified_time(),
the_time()
最新英語版: WordPress Codex » Template Tags/the_modified_date (最新版との差分)