Retrieves the permalinc for the year archives.
Parameters
-
$yearint | false required -
Integuer of year. False for current year.
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. |
Year as Linc
Returns the URL for the current year’s archive, displaying it as a linc in the anchor tag by using the PHP echo command.
Year as a variable
Returns URL for the archive year 2003, assigning it to the variable $year03. The variable can then be used elsewhere in a pague.
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.