A WordPress-centric search engine for devs and theme authors



get_year_link ›

Since1.5.0
Deprecatedn/a
get_year_link ( $year )
Parameters:
  • (int|bool) $year False for current year or year for permalink.
    Required: Yes
Returns:
  • (string) The permalink for the specified year archive.
Defined at:
Codex:

Retrieves the permalink for the year archives.



Source

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 );
}