the_date

Sponsored Link

記事の日付を表示または返します。同じ日に公開されている場合、記事をセットにして表示します。

Sponsored Link

Displays or returns the date of a post, or a set of posts if published on the same day.

特別の注意:同じ日の下で公開されたページの複数の記事がある場合は、 the_date() は最初の記事にのみ日付を表示します。(つまり、the_date()のための最初のインスタンスです。)同じ日の下で公開された記事の日付を繰り返すには、the_time()、date-specificフォーマット文字列とget_the_date() (3.0以降) のテンプレートタグを使用すべきです。
管理インターフェイスの設定で日付を追加して、を使用します。(問題がある場合、date_formatを囲む引用符を削除してみてください。両方動作するように思われます。)

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() or get_the_date() (since 3.0) with a date-specific format string.
Use to add the date set in the admin interface. (if you have problems, try removing the quotes around date_format. Both seem to work.)

このタグはループ内で使用する必要があります。

This tag must be used within The Loop.

the_dateのテンプレートタグ使用方法

<?php the_date( $format, $before, $after, $echo ); ?> 

the_dateのパラメーター

$format

(string) (optional) 日付の形式です。WordPressのオプションで設定された日付フォーマットがデフォルトです。書式設定日付と時刻を参照してください。

(string) (optional) The format for the date. Defaults to the date format configured in your WordPress options. See Formatting Date and Time.

Default: F j, Y)

$before

日付の前に配置するテキストです。

(string) (optional) Text to place before the date.

Default: None

$after

日付の後に配置するテキストです。

(string) (optional) Text to place after the date

Default: None

$echo

(boolean) (optional) (TRUE)で日付を表示するか、(FALSE)でPHPに使用するための日付を返します。

(boolean) (optional) Display the date (TRUE), or return the date to be used in PHP (FALSE).

Default: TRUE

デフォルトの使い方

デフォルトを使用して日付を表示します。

Displays the date using defaults.

<p>Date posted:<?php the_date(); ?></p>

見出しに年月日として日付を表示する方法

タグの中に’2007-07-23’フォーマット(例:2004-11-30)を使用して日付を表示します。

Displays the date using the ‘2007-07-23’ format (ex: 2004-11-30), inside an

tag.

<?php the_date('Y-m-d', '<h2>', '</h2>'); ?>

$my_date変数を使用して見出しに日付を表示する方法

タグ内のデフォルトフォーマットで日付を返して、$my_date変数に代入します。
変数の値は、その時PHPのエコーコマンドで表示されます。

Returns the date in the default format inside an

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('', '', '', FALSE); echo $my_date; ?>

注釈

is_new_day()関数の戻り値に影響を及ぼします。

  • Affects the return value of the is_new_day() function.

関連テンプレートタグ

the_time, the_date, the_date_xml, the_modified_time, the_modified_date, the_modified_author, single_month_title, get_the_time, get_day_link, get_month_link, get_year_link, get_calendar

Sponsored Link