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