get_day_link()
get_day_link( int|false $year, int|false $month, int|fa…
get_day_link( int|false $year, int|false $month, int|false $day )
检索带有年和月的日存档的永久链接。
Retrieves the permalink for the day archives with year and month.
检索带有年和月的日存档的永久链接。
Retrieves the permalink for the day archives with year and month.
目录锚点:#参数#返回#源码#笔记
参数(Parameters)
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| $year | (int | false) | 必需 | 年度整数。本年度为假。 |
| $month | (int | false) | 必需 | 月份的整数。本月为假。 |
| $day | (int | false) | 必需 | 一天的整数。今天是假的。 |
返回(Return)
(string)指定日期、月份和年份存档的永久对齐。
源码(Source)
/**
* Retrieve the permalink for the day archives with year and month.
*
* @since 1.0.0
*
* @global WP_Rewrite $wp_rewrite
*
* @param bool|int $year False for current year. Integer of year.
* @param bool|int $month False for current month. Integer of month.
* @param bool|int $day False for current day. Integer of day.
* @return string The permalink for the specified day, month, and year archive.
*/
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 ) );
}
/**
* Filter 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 );
}| 更新版本 | 源码位置 | 使用 | 被使用 |
|---|---|---|---|
| 1.0.0 | wp-includes/link-template.php:549 | 3 | 7 |
笔记(Notes)
当前日期作为链接
与变量一起使用
类别:WordPress 函数手册、
本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。
还没有任何评论,赶紧来占个楼吧!