检索年份档案的永久链接。

原型

get_year_link( int|bool $year )

参数

$year (int|bool) (Required) 固定链接当前年份或年份为假。

返回值

(string)  指定年份存档的永久链接。

源文件

路径:wp-includes/link-template.php

<?php
...
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 );
	}
	/**
	 * Filters 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 );
}
...
?>

其他

英文文档:https://developer.wordpress.org/reference/functions/get_year_link/