Codex

Template Tags/get day link

Contents

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

edit_post_link, edit_comment_link, link_pages, wp_link_pages, get_year_link, get_month_link, get_day_link

How to pass parameters to tags with PHP function-style parameters

Go to Template Tag index