[WordPress General] 投稿の公開日と最終更新日を表示する

memo.

[markdown]
functions.php に条件に応じて値を返す function を定義する。

“`php:functions.php
function get_mtime($format) {
$mtime = get_the_modified_time(‘Ymd’);
$ptime = get_the_time(‘Ymd’);
if ($ptime > $mtime) {
return get_the_time($format);
} elseif ($ptime === $mtime) {
return null;
} else {
return get_the_modified_time($format);
}
}
“`

投稿テンプレートに追記する。

“`php:single.php

“`

> * [WordPressで最終更新日を表示する方法(予約投稿にも対応) | WP SEOブログ](http://www.seotemplate.biz/blog/wordpress-tips/4019/)
> * [WordPressで記事の最終更新日を表示する方法 HTML5対応版](http://ankare2dx.org/updated-date-html5/)

## 補遺

> * [WordPressブログに更新日を表示 | EasyRamble](http://easyramble.com/wordpress-modified-date.html)
[/markdown]