get_month_link

Definition:
function get_month_link($year, $month) {}

Retrieve the permalink for the month archives with year.

Parameters

  • bool|int $year: False for current year. Integer of year.
  • bool|int $month: False for current month. Integer of month.

Defined filters

  • month_link
    apply_filters('month_link', home_url( user_trailingslashit($monthlink, 'month')
  • month_link
    apply_filters('month_link', home_url( '?m=' . $year . zeroise($month, 2)

Source code

function get_month_link($year, $month) {

	global $wp_rewrite;

	if ( !$year )

		$year = gmdate('Y', current_time('timestamp'));

	if ( !$month )

		$month = gmdate('m', current_time('timestamp'));

	$monthlink = $wp_rewrite->get_month_permastruct();

	if ( !empty($monthlink) ) {

		$monthlink = str_replace('%year%', $year, $monthlink);

		$monthlink = str_replace('%monthnum%', zeroise(intval($month), 2), $monthlink);

		return apply_filters('month_link', home_url( user_trailingslashit($monthlink, 'month') ), $year, $month);

	} else {

		return apply_filters('month_link', home_url( '?m=' . $year . zeroise($month, 2) ), $year, $month);

	}

}

1486

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: