the_date – WordPress*リファレンス
同じ日に発表されるならば、ポストまたは一組のポストの日付を表示するか、返します。
特別な注:複数のポストがSAME DAYの下で発表されるページにあるとき、the_date()、最初のポスト(つまり、the_dateの一審?())の日を表示するだけです。同じ日の下で発表されるポストの日を繰り返すために、あなたはTemplate Tag the_timeを使わなければなりません()日付に特有のフォーマットストリングで。
このタグが、Loopの中で使われなければなりません。
⇒Displays or returns the date of a post, or a set of posts if published on the same day.
SPECIAL NOTE: When there are multiple posts on a page published under the SAME DAY, the_date() only displays the date for the first post (that is, the first instance of the_date()). To repeat the date for posts published under the same day, you should use the Template Tag the_time() with a date-specific format string.
This tag must be used within The Loop.
the_dateのテンプレートタグ使用方法
<?php the_date('format', 'before', 'after', echo); ?>
例
デフォルトの使い方
デフォルトを使っている日付を表示します。
⇒Displays the date using defaults.
<p>Date posted: <?php the_date(); ?></p>
Date as Year, Month, Date in Heading
『2007-07-23』フォーマットを使っている日付を示します(X:2004-11-30)、h2の中に、つきまとってください。
⇒Displays the date using the ‘2007-07-23′ format (ex: 2004-11-30), inside an <h2> tag.
<?php the_date('Y-m-d', '<h2>', ''); ?>
Date in Heading Using $my_date Variable
h2タグ内部にデフォルトフォーマットで日付を返して、それを$my_date変数に割り当てます。変数の価値は、それからPHP反響命令で示されます。
⇒Returns the date in the default format inside an <h2> tag and assigns it to the $my_date variable. The variable’s value is then displayed with the PHP echo command.
<?php $my_date = the_date(<i>, , <i>, FALSE); echo $my_date; ?>
the_dateのパラメーター
format
(string)日付のフォーマット。あなたのWordPressオプションの中で形成された日付表示形式へのデフォルト。フォーマット期日および時間を参照してください。
⇒(string) The format for the date. Defaults to the date format configured in your WordPress options. See Formatting Date and Time.
before
(string)日付の前の場所へのテキスト。デフォルトはありません。
⇒(string) Text to place before the date. There is no default.
after
(string)日付の後の場所へのテキスト。デフォルトはありません。
⇒(string) Text to place after the date. There is no default.
echo
(boolean)日付(TRUE)を表示するか、あるいはPHP(FALSE)の中で使用される日付を返してください。TRUEへのデフォルト。
⇒(boolean) Display the date (TRUE), or return the date to be used in PHP (FALSE). Defaults to TRUE.
関連テンプレートタグ
the_date_xml, the_date, the_time, the_modified_date, |the_modified_time, get_the_time, single_month_title, get_calendar, the_weekday , the_weekday_date
関連記事







