检索包含年份和月份的日期归档的永久链接。
原型
get_day_link( bool|int $year, bool|int $month, bool|int $day )
参数
$year
(bool|int)
(Required)
本年度虚假。一年的整数。
$month
(bool|int)
(Required)
本月为假。一个月的整数。
$day
(bool|int)
(Required)
当天有误。一天的整数。
返回值
(string)
指定日期,月份和年份归档的永久链接。
源文件
路径:wp-includes/link-template.php
<?php
...
function get_day_link($year, $month, $day) {
global $wp_rewrite;
if ( !$year )
$year = gmdate('Y', current_time('timestamp'));
if ( !$month )
$month = gmdate('m', current_time('timestamp'));
if ( !$day )
$day = gmdate('j', current_time('timestamp'));
$daylink = $wp_rewrite->get_day_permastruct();
if ( !empty($daylink) ) {
$daylink = str_replace('%year%', $year, $daylink);
$daylink = str_replace('%monthnum%', zeroise(intval($month), 2), $daylink);
$daylink = str_replace('%day%', zeroise(intval($day), 2), $daylink);
$daylink = home_url( user_trailingslashit( $daylink, 'day' ) );
} else {
$daylink = home_url( '?m=' . $year . zeroise( $month, 2 ) . zeroise( $day, 2 ) );
}
/**
* Filters the day archive permalink.
*
* @since 1.5.0
*
* @param string $daylink Permalink for the day archive.
* @param int $year Year for the archive.
* @param int $month Month for the archive.
* @param int $day The day for the archive.
*/
return apply_filters( 'day_link', $daylink, $year, $month, $day );
}
...
?>
其他
英文文档:https://developer.wordpress.org/reference/functions/get_day_link/