WordPress: Template Tags/get day link:修订间差异

来自站长百科
跳转至: 导航、​ 搜索
无编辑摘要
无编辑摘要
 
第1行: 第1行:
== Description ==
== 描述 ==
== 描述 ==
Returns the daily archive [[WordPress:Glossary#URI and URL|URL]] to a specific year, month and day for use in [[WordPress:Glossary#PHP|PHP]]. It does NOT display the URL. If year, month and day parameters are set to <tt>&#39;&#39;</tt>, the tag returns the URL for the current day's archive.


返回某年某月某日的归档[[WordPress:Glossary#URI and URL|URL]],用于[[WordPress:Glossary#PHP|PHP]]中。不显示URL。如果年份和月份和日参数设置为<tt>&#39;&#39;</tt>,标签返回了当日归档的URL。
返回某年某月某日的归档[[WordPress:Glossary#URI and URL|URL]],用于[[WordPress:Glossary#PHP|PHP]]中。不显示URL。如果年份和月份和日参数设置为<tt>&#39;&#39;</tt>,标签返回了当日归档的URL。
== Usage ==


== 用法 ==
== 用法 ==


%%% <?php get_day_link('year', 'month', 'day'); ?> %%%
%%% <?php get_day_link('year', 'month', 'day'); ?> %%%
%%% <?php get_day_link('year', 'month', 'day'); ?> %%%
== Examples ==


== 例子==
== 例子==
=== Current Day as Link ===


=== 当天作为链接 ===
=== 当天作为链接 ===
Returns the URL to the current day's archive as a link by displaying it within an anchor tag with the PHP echo command.


返回当天存档的URL,作为链接,将这个URL放到一个anchor标签中和PHP echo命令一起显示。
返回当天存档的URL,作为链接,将这个URL放到一个anchor标签中和PHP echo命令一起显示。
&lt;a href="<?php echo get_day_link(<nowiki>''</nowiki>, <nowiki>''</nowiki>, <nowiki>''</nowiki>); ?>"&gt;Today's posts&lt;/a&gt;


&lt;a href="<?php echo get_day_link(<nowiki>''</nowiki>, <nowiki>''</nowiki>, <nowiki>''</nowiki>); ?>"&gt;Today's posts&lt;/a&gt;
&lt;a href="<?php echo get_day_link(<nowiki>''</nowiki>, <nowiki>''</nowiki>, <nowiki>''</nowiki>); ?>"&gt;Today's posts&lt;/a&gt;
=== Use With Variables ===


=== 与变数一起使用 ===
=== 与变数一起使用 ===


PHP code block for use within [[WordPress:The Loop]]: Assigns year, month and day of a post to the variables $arc_year, $arc_month and $arc_day. These are used with the get_day_link() tag, which returns the URL as a link to the daily archive for that post, displaying it within an anchor tag with the PHP echo command. See [[WordPress:Formatting Date and Time]] for info on format strings used in [[WordPress:Template Tags/get_the time|get_the_time()]] tag.
[[WordPress:The Loop|The Loop]]内使用的PHP代码块:将一篇文章的年份和月份和日指定为变数$arc_year, $arc_month和$arc_day。这些变数与get_day_link()标签一起使用,get_day_link()标签返回URL作为一个链接,连接到文章的每日存档中,在一个anchor 标签中,将它和PHP echo命令一起显示。请看看[[WordPress:Formatting Date and Time|日期和时间格式]],有关用在[[WordPress:Template Tags/get_the time|get_the_time()]]标签中的格式字符串的信息。
 
[[WordPress:The Loop|The Loop]]内使用的PHP代码块:将一篇文章的年份和月份和日指定为变数$arc_年份, $arc_月份和$arc_日。这些变数与get_day_link()标签一起使用,get_day_link()标签返回URL作为一个链接,连接到文章的每日存档中,在一个anchor 标签中,将它和PHP echo命令一起显示。请看看[[WordPress:Formatting Date and Time|日期和时间格式]],有关用在[[WordPress:Template Tags/get_the time|get_the_time()]]标签中的格式字符串的信息。
 
<?php
$arc_year = get_the_time('Y');
$arc_month = get_the_time('m');
$arc_day = get_the_time('d');
?>
&lt;a href="<?php echo get_day_link(<nowiki>"$arc_year"</nowiki>, <nowiki>"$arc_month"</nowiki>,
<nowiki>"$arc_day"</nowiki>); ?>"&gt;this day's posts&lt;/a&gt;




第55行: 第27行:
  &lt;a href="<?php echo get_day_link(<nowiki>"$arc_year"</nowiki>, <nowiki>"$arc_month"</nowiki>,  
  &lt;a href="<?php echo get_day_link(<nowiki>"$arc_year"</nowiki>, <nowiki>"$arc_month"</nowiki>,  
  <nowiki>"$arc_day"</nowiki>); ?>"&gt;this day's posts&lt;/a&gt;
  <nowiki>"$arc_day"</nowiki>); ?>"&gt;this day's posts&lt;/a&gt;
== Parameters ==


== 参数==
== 参数==


; year : (''integer'') The year for the archive. Use <tt>&#39;&#39;</tt> to assign current year.
; year : (''integer'') 归档的年份。使用<tt>&#39;&#39;</tt>指定当前的年份。
; 年份 : (''整数'')归档的年份。使用<tt>&#39;&#39;</tt>指定当前的年份。
; month : (''integer'') The month for archive. Use <tt>&#39;&#39;</tt> to assign current month.
 
; 月份 : (''整数'')归档的月份。使用<tt>&#39;&#39;</tt>指定当前的月份。
 
; day : (''integer'') The day for archive. Use <tt>&#39;&#39;</tt> to assign current day.
 
; 日 : (''整数'')归档的那一日。使用<tt>&#39;&#39;</tt>指定当天。


== Related ==
; month : (''integer'') 归档的月份。使用<tt>&#39;&#39;</tt>指定当前的月份。


{{Tag Link Tags}}
; day : (''integer'') 归档的那一日。使用<tt>&#39;&#39;</tt>指定当天。


{{PHP Function Tag Footer}}
== 相关的 ==
== 相关的 ==
{{标签 链接标签}}
{{标签 链接标签}}


{{PHP函数标签 页底文字}}
{{PHP函数标签 页底文字}}

2008年7月16日 (三) 11:36的最新版本

描述[ ]

返回某年某月某日的归档URL,用于PHP中。不显示URL。如果年份和月份和日参数设置为'',标签返回了当日归档的URL。

用法[ ]

%%% <?php get_day_link('year', 'month', 'day'); ?> %%%

例子[ ]

当天作为链接[ ]

返回当天存档的URL,作为链接,将这个URL放到一个anchor标签中和PHP echo命令一起显示。

<a href="<?php echo get_day_link('', '', ''); ?>">Today's posts</a>

与变数一起使用[ ]

The Loop内使用的PHP代码块:将一篇文章的年份和月份和日指定为变数$arc_year, $arc_month和$arc_day。这些变数与get_day_link()标签一起使用,get_day_link()标签返回URL作为一个链接,连接到文章的每日存档中,在一个anchor 标签中,将它和PHP echo命令一起显示。请看看日期和时间格式,有关用在get_the_time()标签中的格式字符串的信息。


<?php

$arc_year = get_the_time('Y');
$arc_month = get_the_time('m');
$arc_day = get_the_time('d');
?>
<a href="<?php echo get_day_link("$arc_year", "$arc_month", 
"$arc_day"); ?>">this day's posts</a>

参数[ ]

year
(integer) 归档的年份。使用''指定当前的年份。
month
(integer) 归档的月份。使用''指定当前的月份。
day
(integer) 归档的那一日。使用''指定当天。

相关的[ ]

模板:标签 链接标签

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