get_day_link

The timeline below displays how wordpress function get_day_link has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 5.6

/**
 * Retrieves the permalink for the day archives with year and month.
 *
 * @since 1.0.0
 *
 * @global WP_Rewrite $wp_rewrite WordPress rewrite component.
 *
 * @param int|false $year  Integer of year. False for current year.
 * @param int|false $month Integer of month. False for current month.
 * @param int|false $day   Integer of day. False for current day.
 * @return string The permalink for the specified day, month, and year archive.
 */
function get_day_link($year, $month, $day)
{
    global $wp_rewrite;
    if (!$year) {
        $year = current_time('Y');
    }
    if (!$month) {
        $month = current_time('m');
    }
    if (!$day) {
        $day = current_time('j');
    }
    $daylink = $wp_rewrite->get_day_permastruct();
    if (!empty($daylink)) {
        $daylink = str_replace('%year%', $year, $daylink);
        $daylink = str_replace('%monthnum%', zeroise((int) $month, 2), $daylink);
        $daylink = str_replace('%day%', zeroise((int) $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);
}

WordPress Version: 5.4

/**
 * Retrieves the permalink for the day archives with year and month.
 *
 * @since 1.0.0
 *
 * @global WP_Rewrite $wp_rewrite WordPress rewrite component.
 *
 * @param int|false $year  Integer of year. False for current year.
 * @param int|false $month Integer of month. False for current month.
 * @param int|false $day   Integer of day. False for current day.
 * @return string The permalink for the specified day, month, and year archive.
 */
function get_day_link($year, $month, $day)
{
    global $wp_rewrite;
    if (!$year) {
        $year = current_time('Y');
    }
    if (!$month) {
        $month = current_time('m');
    }
    if (!$day) {
        $day = current_time('j');
    }
    $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);
}

WordPress Version: 5.3

/**
 * Retrieves the permalink for the day archives with year and month.
 *
 * @since 1.0.0
 *
 * @global WP_Rewrite $wp_rewrite WordPress rewrite component.
 *
 * @param bool|int $year  False for current year. Integer of year.
 * @param bool|int $month False for current month. Integer of month.
 * @param bool|int $day   False for current day. Integer of day.
 * @return string The permalink for the specified day, month, and year archive.
 */
function get_day_link($year, $month, $day)
{
    global $wp_rewrite;
    if (!$year) {
        $year = current_time('Y');
    }
    if (!$month) {
        $month = current_time('m');
    }
    if (!$day) {
        $day = current_time('j');
    }
    $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);
}

WordPress Version: 5.2

/**
 * Retrieves the permalink for the day archives with year and month.
 *
 * @since 1.0.0
 *
 * @global WP_Rewrite $wp_rewrite
 *
 * @param bool|int $year  False for current year. Integer of year.
 * @param bool|int $month False for current month. Integer of month.
 * @param bool|int $day   False for current day. Integer of day.
 * @return string The permalink for the specified day, month, and year archive.
 */
function get_day_link($year, $month, $day)
{
    global $wp_rewrite;
    if (!$year) {
        $year = current_time('Y');
    }
    if (!$month) {
        $month = current_time('m');
    }
    if (!$day) {
        $day = current_time('j');
    }
    $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);
}

WordPress Version: 4.6

/**
 * Retrieves the permalink for the day archives with year and month.
 *
 * @since 1.0.0
 *
 * @global WP_Rewrite $wp_rewrite
 *
 * @param bool|int $year  False for current year. Integer of year.
 * @param bool|int $month False for current month. Integer of month.
 * @param bool|int $day   False for current day. Integer of day.
 * @return string The permalink for the specified day, month, and year archive.
 */
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);
}

WordPress Version: 4.3

/**
 * Retrieve the permalink for the day archives with year and month.
 *
 * @since 1.0.0
 *
 * @global WP_Rewrite $wp_rewrite
 *
 * @param bool|int $year  False for current year. Integer of year.
 * @param bool|int $month False for current month. Integer of month.
 * @param bool|int $day   False for current day. Integer of day.
 * @return string The permalink for the specified day, month, and year archive.
 */
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));
    }
    /**
     * Filter 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);
}

WordPress Version: 4.1

/**
 * Retrieve the permalink for the day archives with year and month.
 *
 * @since 1.0.0
 *
 * @param bool|int $year False for current year. Integer of year.
 * @param bool|int $month False for current month. Integer of month.
 * @param bool|int $day False for current day. Integer of day.
 * @return string The permalink for the specified day, month, and year archive.
 */
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));
    }
    /**
     * Filter 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);
}

WordPress Version: 3.9

/**
 * Retrieve the permalink for the day archives with year and month.
 *
 * @since 1.0.0
 *
 * @param bool|int $year False for current year. Integer of year.
 * @param bool|int $month False for current month. Integer of month.
 * @param bool|int $day False for current day. Integer of day.
 * @return string
 */
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));
    }
    /**
     * Filter 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);
}

WordPress Version: 3.7

/**
 * Retrieve the permalink for the day archives with year and month.
 *
 * @since 1.0.0
 *
 * @param bool|int $year False for current year. Integer of year.
 * @param bool|int $month False for current month. Integer of month.
 * @param bool|int $day False for current day. Integer of day.
 * @return string
 */
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);
        return apply_filters('day_link', home_url(user_trailingslashit($daylink, 'day')), $year, $month, $day);
    } else {
        return apply_filters('day_link', home_url('?m=' . $year . zeroise($month, 2) . zeroise($day, 2)), $year, $month, $day);
    }
}