WordPress.org

Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/get day link

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

Parameters

year
(boolean/integer) (required) The year for the archive. Use '' to assign current year.
Default: None
month
(boolean/integer) (required) The month for the archive. Use '' to assign current month.
Default: None
day
(boolean/integer) (required) The day for the archive. Use '' to assign current day.
Default: None

Return Values

(string) 
The URL for the day's archive

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 
$archive_year  = get_the_time('Y'); 
$archive_month = get_the_time('m'); 
$archive_day   = get_the_time('d'); 
?>
<a href="<?php echo get_day_link( $archive_year, $archive_month, $archive_day); ?>">This day's posts</a>

Changelog

Since: 1.0.0

Source File

get_day_link() is located in wp-includes/link-template.php.

Related

get_calendar(), get_day_link(), get_month_link(), get_the_date(), get_the_time(), get_year_link(), single_month_title(), the_date(), the_date_xml(), the_modified_date(), get_the_modified_date(), the_modified_time(), get_the_modified_time(), the_time()

See also index of Function Reference and index of Template Tags.