WordPress: Template Tags/the date:修订间差异

来自站长百科
跳转至: 导航、​ 搜索
(新页面: == Description == Displays or returns the date of a post, or a set of posts if published on the same day. <div style="text-decoration:none; padding: 10px; margin: 10px 0px 5px; backgro...)
 
无编辑摘要
第1行: 第1行:
== Description ==
== Description ==
== 描述 ==


Displays or returns the date of a post, or a set of posts if published on the same day.  
Displays or returns the date of a post, or a set of posts if published on the same day.  
如果文章都是以同样的方式发表的,显示或者返回一篇文章或者一组文章的发表日期。


<div style="text-decoration:none; padding: 10px; margin: 10px 0px 5px; background-color: #f0f0f0; border: 1px solid darkslateblue">'''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 [[WordPress:Template Tags|Template Tag]] [[WordPress:Template Tags/the time|the_time()]] with a [[WordPress:Formatting_Date_and_Time|date-specific format string]].</div>
<div style="text-decoration:none; padding: 10px; margin: 10px 0px 5px; background-color: #f0f0f0; border: 1px solid darkslateblue">'''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 [[WordPress:Template Tags|Template Tag]] [[WordPress:Template Tags/the time|the_time()]] with a [[WordPress:Formatting_Date_and_Time|date-specific format string]].</div>
<div style="text-decoration:none; padding: 10px; margin: 10px 0px 5px; background-color: #f0f0f0; border: 1px solid darkslateblue">'''特别要注意:''' 当一个网页上有几篇文章,这些文章是在同一天发表的, the_日期() 只会显示第一篇文章的发表日期, (就是, the_日期()的第一个例子)。要重复在同一天发表的文章的日期,你应该使用 [[WordPress:Template Tags|模板标签]] [[WordPress:Template Tags/the time|the_时间()]] 拥有一个[[WordPress:Formatting_Date_and_Time|特别日期格式字符串]]。</div>


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


%%% <?php the_date('format', 'before', 'after', echo); ?> %%%
%%% <?php the_date('format', 'before', 'after', echo); ?> %%%
== 用法 ==
%%% <?php the_日期('格式', '之前', '之后', echo); ?> %%%


== Examples ==
== Examples ==
第18行: 第30行:


  &lt;p&gt;Date posted: <?php the_date(); ?>&lt;/p&gt;
  &lt;p&gt;Date posted: <?php the_date(); ?>&lt;/p&gt;
== 例子 ==
===默认用法 ===
使用默认格式,显示日期。
&lt;p&gt;文章发表的日期: <?php the_日期(); ?>&lt;/p&gt;


=== Date as Year, Month, Date in Heading ===
=== Date as Year, Month, Date in Heading ===
=== 标签中的年,月,日,日期===


Displays the date using the <code>'2007-07-23'</code> format (ex: 2004-11-30), inside an &lt;h2&gt; tag.
Displays the date using the <code>'2007-07-23'</code> format (ex: 2004-11-30), inside an &lt;h2&gt; tag.
使用<code>'2007-07-23'</code>格式 (例如: 2004-11-30)显示日期,在&lt;h2&gt;标签内部。


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


=== Date in Heading Using $my_date Variable===
=== Date in Heading Using $my_date Variable===
===标题中的日期,使用$my_date 变数===


Returns the date in the default format inside an &lt;h2&gt; tag and assigns it to the $my_date variable. The variable's value is then displayed with the PHP echo command.
Returns the date in the default format inside an &lt;h2&gt; tag and assigns it to the $my_date variable. The variable's value is then displayed with the PHP echo command.
在&lt;h2&gt;标签中,将日期返回为默认格式,并且将日期分发给$我的_日期变数。变数的值,就会与PHP echo命令行一起显示。


  <?php $my_date = the_date(&#39;&#39;, &#39;&#39;, &#39;&#39;, FALSE); echo $my_date; ?>
  <?php $my_date = the_date(&#39;&#39;, &#39;&#39;, &#39;&#39;, FALSE); echo $my_date; ?>
<?php $我的_日期 = the_日期(&#39;&#39;, &#39;&#39;, &#39;&#39;, 错误的); echo $我的_日期; ?>


== Parameters ==
== Parameters ==
== 参数 ==


; format : (''string'') The format for the date. Defaults to the date format configured in your WordPress options. See [[WordPress:Formatting Date and Time]].
; format : (''string'') The format for the date. Defaults to the date format configured in your WordPress options. See [[WordPress:Formatting Date and Time]].
第37行: 第72行:
; after : (''string'') Text to place after the date. There is no default.
; after : (''string'') Text to place after the date. There is no default.
; echo : (''boolean'') Display the date (<tt>TRUE</tt>), or return the date to be used in PHP (<tt>FALSE</tt>). Defaults to <tt>TRUE</tt>.
; echo : (''boolean'') Display the date (<tt>TRUE</tt>), or return the date to be used in PHP (<tt>FALSE</tt>). Defaults to <tt>TRUE</tt>.
;格式:(''string'')日期的格式。默认为WordPress选项中设置的日期格式。请看看[[WordPress:Formatting Date and Time|日期和时间格式]]。
;之前:(''string'')置于日期前的文本。没有默认设置。
;之后:(''string'')置于日期后的文本。没有默认设置。
; echo : (''boolean'')显示日期(<tt>正确的</tt>),或者返回日期用于PHP(<tt>错误的</tt>)。默认为<tt>正确的</tt>。


== Related ==
== Related ==
第43行: 第83行:


{{PHP Function Tag Footer}}
{{PHP Function Tag Footer}}
== 相关的 ==
{{标签 日期 标签}}
{{PHP 函数 标签 页底文字}}

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 函数 标签 页底文字