get_day_link()
最后更新于:2021-11-26 09:05:10
get_day_link( int|false$year, int|false$month, int|false$day)Retrieves the permalink for the day archives with year and month.
参数
- $year
-
(int|false) (Required) Integer of year. False for current year.
- $month
-
(int|false) (Required) Integer of month. False for current month.
- $day
-
(int|false) (Required) Integer of day. False for current day.
响应
(string) The permalink for the specified day, month, and year archive.
源文件
文件: gc-includes/link-template.php
function get_day_link( $year, $month, $day ) {
global $gc_rewrite;
if ( ! $year ) {
$year = current_time( 'Y' );
}
if ( ! $month ) {
$month = current_time( 'm' );
}
if ( ! $day ) {
$day = current_time( 'j' );
}
$daylink = $gc_rewrite->get_day_permastruct();
if ( ! empty( $daylink ) ) {
$daylink = str_replace( '%year%', $year, $daylink );
$daylink = str_replace( '%monthnum%', zeroise( (int) $month, 2 ), $daylink );
$daylink = str_replace( '%day%', zeroise( (int) $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 );
}