WordPress:Template Tags/get day link

来自站长百科
Xxf3325讨论 | 贡献2008年6月27日 (五) 10:25的版本 (新页面: == Description == Returns the daily archive URL to a specific year, month and day for use in PHP. It does NOT display the UR...)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
跳转至: 导航、​ 搜索

Description

Returns the daily archive URL to a specific year, month and day for use in PHP. It does NOT display the URL. If year, month and day parameters are set to '', the tag returns the URL for the current day's archive.

Usage

%%% <?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.

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

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 get_the_time() tag.

<?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>

Parameters

year
(integer) The year for the archive. Use '' to assign current year.
month
(integer) The month for archive. Use '' to assign current month.
day
(integer) The day for archive. Use '' to assign current day.

Related

模板:Tag Link Tags

模板:PHP Function Tag Footer