2022年04月25日

WP関数:the_modified_time()

この関数の説明

WP関数の the_modified_time() は、固定ページや投稿の最終編集日の時刻を表示する関数です。

 


関数

the_modified_time( $format )

 


パラメータ

$format文字列) (オプション

時間の出力形式を指定します。

省略した場合はWordPressの[設定→一般]の[時刻形式]フォーマットで出力されます。

時刻のフォーマット記号

分類 記号 解説
24時間表示 G

(大文字のG)

1桁又は2桁表示(0~23)
H

(大文字のH)

2桁表示(00~23)
12時間表示 A

(大文字のA)

AM又はPM
a

(子文字のA)

am又はpm
g

(子文字のG)

1桁又は2桁表示(0~11)
h

(子文字のH)

2桁表示(00~11)
i

(子文字のI)

2桁表示(00~59)
s

(子文字のS)

2桁表示(00~59)

例)'g:i A'と指定した場合、2:36 PMの形式で表示されます。

 


利用例

①一般的な使い方

下記は文書の最終更新日時と文書タイトル(リンク付き)を書き出すサンプルです。

<?php while(have_posts()):the_post(); ?>
	<?php the_modified_date();the_modified_time();?><br>
	<a href='<?php the_permalink(); ?>'><?php the_title(); ?></a>
<?php endwhile;?>

■2行目で最終更新日と最終更新時間を表示しています。

尚、the_modified_date()で、時刻のフォーマットも指定をすると時刻も併せて表示させる事もできます。

■文書のタイトルはthe_title()、文書のURLはthe_permalink()を参照してください。

 


関連情報

関連関数は 文書情報関連関数 を参照してください。

 

 

関数一覧
  • 1.WPのエスケープ処理
  • 2.WPプログラムの基本
  • 3.ヘッダ/フッタ/サイドバで使われる関数
  • 4.DBからの読込関数
  • 5.一般テンプレートの中で使われる関数
  • 6.その他のWP関数
  • add_shortcode()
  • bloginfo()
  • body_class()
  • date_i18n()
  • dynamic_sidebar()
  • edit_post_link()
  • esc_attr()
  • esc_html_e()
  • esc_html()
  • esc_url()
  • get_ancestors()
  • get_cat_ID()
  • get_cat_name()
  • get_category_link()
  • get_category_parents()
  • get_category()
  • get_footer()
  • get_header()
  • get_home_url()
  • get_post_format()
  • get_post_meta()
  • get_post_thumbnail_id()
  • get_query_var()
  • get_search_query()
  • get_sidebar()
  • get_site_url()
  • get_stylesheet_directory_uri()
  • get_stylesheet_uri()
  • get_template_directory_uri()
  • get_template_part()
  • get_the_category()
  • get_the_content()
  • get_the_date()
  • get_the_excerpt()
  • get_the_ID()
  • get_the_modified_date()
  • get_the_modified_time()
  • get_the_permalink()
  • get_the_post_thumbnail()
  • get_the_tags()
  • get_the_time()
  • get_the_title()
  • get_uploaded_header_images()
  • get_year_link()
  • has_category()
  • has_custom_logo()
  • has_header_image()
  • has_header_video()
  • has_nav_menu()
  • has_post_thumbnail()
  • has_tag()
  • header_image()
  • home_url()
  • is_admin()
  • is_category()
  • is_date()
  • is_front_page()
  • is_home()
  • is_main_query()
  • is_page()
  • is_search()
  • is_single()
  • language_attributes()
  • the_category()
  • the_content()
  • the_custom_header_markup()
  • the_custom_logo()
  • the_date()
  • the_excerpt()
  • the_ID()
  • the_modified_date()
  • the_modified_time()
  • the_permalink()
  • the_post_thumbnail()
  • the_search_query()
  • the_tags()
  • the_time()
  • the_title()
  • update_post_meta()
  • wp_get_attachment_image_src()
  • wp_nav_menu()
  • WP_Query()