wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren



get_month_link › WordPress Function

Seit1.0.0
Veraltetn/v
get_month_link ( $year, $month )
Parameter: (2)
  • (int|false) $year Integer of year. False for current year.
    Erforderlich: Ja
  • (int|false) $month Integer of month. False for current month.
    Erforderlich: Ja
Gibt zurück:
  • (string) The permalink for the specified month and year archive.
Definiert in:
Codex:

Retrieves the permalink for the month archives with year.



Quellcode

function get_month_link( $year, $month ) {
	global $wp_rewrite;
	if ( ! $year ) {
		$year = current_time( 'Y' );
	}
	if ( ! $month ) {
		$month = current_time( 'm' );
	}
	$monthlink = $wp_rewrite->get_month_permastruct();
	if ( ! empty( $monthlink ) ) {
		$monthlink = str_replace( '%year%', $year, $monthlink );
		$monthlink = str_replace( '%monthnum%', zeroise( (int) $month, 2 ), $monthlink );
		$monthlink = home_url( user_trailingslashit( $monthlink, 'month' ) );
	} else {
		$monthlink = home_url( '?m=' . $year . zeroise( $month, 2 ) );
	}

	/**
	 * Filters the month archive permalink.
	 *
	 * @since 1.5.0
	 *
	 * @param string $monthlink Permalink for the month archive.
	 * @param int    $year      Year for the archive.
	 * @param int    $month     The month for the archive.
	 */
	return apply_filters( 'month_link', $monthlink, $year, $month );
}