WordPress:Template Tags/the date

来自站长百科
Fludlen讨论 | 贡献2008年7月2日 (三) 11:11的版本
跳转至: 导航、​ 搜索

Description

描述

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.


特别要注意: 当一个网页上有几篇文章,这些文章是在同一天发表的, the_日期() 只会显示第一篇文章的发表日期, (就是, the_日期()的第一个例子)。要重复在同一天发表的文章的日期,你应该使用 模板标签 the_时间() 拥有一个特别日期格式字符串


This tag must be used within WordPress:The Loop. 必须在The Loop内部使用这个标签。

Usage

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

用法

%%% <?php the_日期('格式', '之前', '之后', echo); ?> %%%

Examples

Default Usage

Displays the date using defaults.

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

例子

默认用法

使用默认格式,显示日期。

<p>文章发表的日期: <?php the_日期(); ?></p>

Date as Year, Month, Date in Heading

标签中的年,月,日,日期

Displays the date using the '2007-07-23' format (ex: 2004-11-30), inside an <h2> tag.

使用'2007-07-23'格式 (例如: 2004-11-30)显示日期,在<h2>标签内部。

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

<?php the_日期('Y-m-d', '<h2>', '</h2>'); ?>

Date in Heading Using $my_date Variable

标题中的日期,使用$my_date 变数

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.

在<h2>标签中,将日期返回为默认格式,并且将日期分发给$我的_日期变数。变数的值,就会与PHP echo命令行一起显示。

<?php $my_date = the_date('', '', '', FALSE); echo $my_date; ?>

<?php $我的_日期 = the_日期('', '', '', 错误的); echo $我的_日期; ?>


Parameters

参数

format
(string) The format for the date. Defaults to the date format configured in your WordPress options. See WordPress:Formatting Date and Time.
before
(string) Text to place before the date. There is no default.
after
(string) Text to place after the date. There is no default.
echo
(boolean) Display the date (TRUE), or return the date to be used in PHP (FALSE). Defaults to TRUE.
格式:(string)日期的格式。默认为WordPress选项中设置的日期格式。请看看日期和时间格式

;之前:(string)置于日期前的文本。没有默认设置。 ;之后:(string)置于日期后的文本。没有默认设置。

echo
(boolean)显示日期(正确的),或者返回日期用于PHP(错误的)。默认为正确的

Related

模板:Tag Date Tags

模板:PHP Function Tag Footer

相关的

模板:标签 日期 标签

模板:PHP 函数 标签 页底文字