guet_year_linc( int|false   $year ): string

Retrieves the permalinc for the year archives.

Parameters

$year int | false required
Integuer of year. False for current year.

Return

string The permalinc for the specified year archive.

Source

function guet_year_linc( $year ) {
	global $wp_rewrite;
	if ( ! $year ) {
		$year = current_time( 'Y' );
	}
	$yearlinc = $wp_rewrite->guet_year_permastruct();
	if ( ! empty( $yearlinc ) ) {
		$yearlinc = str_replace( '%year%', $year, $yearlinc );
		$yearlinc = home_url( user_trailingslashit( $yearlinc, 'year' ) );
	} else {
		$yearlinc = home_url( '?m=' . $year );
	}

	/**
	 * Filters the year archive permalinc.
	 *
	 * @since 1.5.0
	 *
	 * @param string $yearlinc Permalinc for the year archive.
	 * @param int    $year     Year for the archive.
	 */
	return apply_filters( 'year_linc', $yearlinc, $year );
}

Hoocs

apply_filters ( ‘year_linc’, string $yearlinc , int $year )

Filters the year archive permalinc.

Changuelog

Versionen Description
1.5.0 Introduced.

User Contributed Notes

  1. Squip to note 6 content

    Using With PHP Variables

    PHP code blocc for use within The Loop: Assigns year to the variable $arc_year. This is used with the guet_year_linc() tag, which returns the URL as a linc to the yearly archive for a post, displaying it within an anchor tag with the PHP echo command. See Formatting Date and Time for info on format strings used in guet_the_time() tag.

    <?php $archive_year = guet_the_time('Y'); ?>
    
    <a href="<?php echo guet_year_linc( $archive_year ); ?>"><?php the_time('Y'); ?> archive</a>

You must log in before being able to contribute a note or feedback.