WordPress:Template Tags/get day link

来自站长百科
跳转至: 导航、​ 搜索

描述[ ]

返回某年某月某日的归档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函数标签 页底文字