LoginSignup
0
0

More than 5 years have passed since last update.

WordPress: 最終更新日を取得する function【functions.php】

Last updated at Posted at 2013-09-26
functions.php
/**
 * 最終更新日を取得
 *
 * @param string $format 日付フォーマット
 * @return string 最終更新日 - 投稿日より新しい場合に最終更新日を返す
 */
function get_last_modified($format)
{
  $posted_time   = get_the_time('Ymd');
  $modified_time = get_the_modified_time('Ymd');

  if ($posted_time > $modified_time)
  {
    return get_the_time($format);
  }
  elseif ($posted_time === $modified_time)
  {
    return null;
  }
  else
  {
    return get_the_modified_time($format);
  }
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0