A WordPress-centric search engine for devs and theme authors



get_day_link ›

Since1.0.0
Deprecatedn/a
get_day_link ( $year, $month, $day )
Parameters: (3)
  • (bool|int) $year False for current year. Integer of year.
    Required: Yes
  • (bool|int) $month False for current month. Integer of month.
    Required: Yes
  • (bool|int) $day False for current day. Integer of day.
    Required: Yes
Returns:
  • (string) The permalink for the specified day, month, and year archive.
Defined at:
Codex:

Retrieves the permalink for the day archives with year and month.



Source

function get_day_link( $year, $month, $day ) {
	global $wp_rewrite;
	if ( ! $year ) {
		$year = gmdate( 'Y', current_time( 'timestamp' ) );
	}
	if ( ! $month ) {
		$month = gmdate( 'm', current_time( 'timestamp' ) );
	}
	if ( ! $day ) {
		$day = gmdate( 'j', current_time( 'timestamp' ) );
	}

	$daylink = $wp_rewrite->get_day_permastruct();
	if ( ! empty( $daylink ) ) {
		$daylink = str_replace( '%year%', $year, $daylink );
		$daylink = str_replace( '%monthnum%', zeroise( intval( $month ), 2 ), $daylink );
		$daylink = str_replace( '%day%', zeroise( intval( $day ), 2 ), $daylink );
		$daylink = home_url( user_trailingslashit( $daylink, 'day' ) );
	} else {
		$daylink = home_url( '?m=' . $year . zeroise( $month, 2 ) . zeroise( $day, 2 ) );
	}

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