get_year_link()
get_year_link( int|false $year ) 检索年度存档的永久链接。Retrieves …
get_year_link( int|false $year )
检索年度存档的永久链接。
Retrieves the permalink for the year archives.
目录锚点:#参数#返回#源码#笔记
参数(Parameters)
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| $year | (int | false) | 必需 | 年度整数。本年度为假。 |
返回(Return)
(string)指定年份存档的永久对齐。
源码(Source)
/**
* Retrieve the permalink for the year archives.
*
* @since 1.5.0
*
* @global WP_Rewrite $wp_rewrite
*
* @param int|bool $year False for current year or year for permalink.
* @return string The permalink for the specified year archive.
*/
function get_year_link($year) {
global $wp_rewrite;
if ( !$year )
$year = gmdate('Y', current_time('timestamp'));
$yearlink = $wp_rewrite->get_year_permastruct();
if ( !empty($yearlink) ) {
$yearlink = str_replace('%year%', $year, $yearlink);
$yearlink = home_url( user_trailingslashit( $yearlink, 'year' ) );
} else {
$yearlink = home_url( '?m=' . $year );
}
/**
* Filter the year archive permalink.
*
* @since 1.5.0
*
* @param string $yearlink Permalink for the year archive.
* @param int $year Year for the archive.
*/
return apply_filters( 'year_link', $yearlink, $year );
}| 更新版本 | 源码位置 | 使用 | 被使用 |
|---|---|---|---|
| 1.5.0 | wp-includes/link-template.php:473 | 2 | 6 |
笔记(Notes)
年份作为链接
以年为变量
与PHP变量一起使用
类别:WordPress 函数手册、
本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。
还没有任何评论,赶紧来占个楼吧!