説明
the_modified_date() は、投稿の最終更新日を出力する関数です。
基本構文
the_modified_date( string $format = '', string $before = '', string $after = '', bool $display = true ): string|void
引数
$format:日付の書式(省略すると、設定の日付形式)$before:日付の前に出力する文字列$after:日付の後に出力する文字列$display:trueで出力、falseで戻り値として返す
戻り値
$display が true(既定)のときは、出力のみ。false のときは、文字列を返します。
使い方(サンプル)
the_modified_date( 'Y年n月j日', '更新日:' );
注意点
- 一度も更新していない投稿では、公開日と同じ値になります。
- ループの中で使います。
実務での使いどころ
- 記事の「更新日」を表示するとき。
よくあるミスと対処
- 値として使いたいのに、これを使っている。値は
get_the_modified_date()で取得する。 - 公開日の関数
the_date()と取り違える。
NG例
$date = the_modified_date(); // 出力されるだけで、変数には入らない
OK例
$date = get_the_modified_date( 'Y年n月j日' );
使い分け早見表
| 関数 | 役割 |
|---|---|
the_modified_date() |
更新日を出力する |
get_the_modified_date() |
更新日を、文字列で取得する |
get_the_date() |
公開日を、文字列で取得する |
関連項目
get_the_modified_date()、get_the_date()、the_date()
公式リファレンス:the_modified_date() | WordPress Developer Resources

コメント