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