WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Broken calendar links (3 posts)

  1. deadlove
    Member
    Posted 8 years ago #

    Hi! I added a calendar (through the widgets plugin) to my sidebar. The links for the days with posts lead to a 404 error page. I found that the end / character is what gives the 404. For example, if I type in:

    http://www.domain.com/2006/05/15/

    it will be broken. But if I type in

    http://www.domain.com/2006/05/15

    it works fine. The ending / doesn't seem to affect the month, year, category, or post links... just the day, which is what breaks my calendar. Is there a way to fix this, by either changing the calendar to create links without the /, or by fixing the day links themselves? (Sorry if this is all very confusing! I am having a hard time typing it out.) Additionally, the 404 page that it goes to is NOT the same as the included WP 404 page; it goes to my server's default.

    If it is of any help, I am using WP 2.02, the Regulus theme (http://www.binarymoon.co.uk/projects/regulus/) and my permalink structure is date and name based. Thanks for any help you are able to provide!

  2. mimko
    Member
    Posted 8 years ago #

    I had the same problem, so I played around with the templates-functions-links.php file (found in wp-includes directory) and changed:

    function get_day_link($year, $month, $day) {
    global $querystring_start, $querystring_equal;
    if (!$year) $year = gmdate('Y', time()+(get_settings('gmt_offset') * 3600));
    if (!$month) $month = gmdate('m', time()+(get_settings('gmt_offset') * 3600));
    if (!$day) $day = gmdate('j', time()+(get_settings('gmt_offset') * 3600));
    if ('' != get_settings('permalink_structure')) {
    $off = strpos(get_settings('permalink_structure'), '%day%');
    $offset = $off + 6;
    $daylink = substr(get_settings('permalink_structure'), 0, $offset);
    if ('/' != substr($daylink, -1)) $daylink = substr($daylink, 0, -1);
    $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 = str_replace('%post_id%', '', $daylink);
    return get_settings('home') . $daylink;
    } else {
    return get_settings('home') .'/'. get_settings('blogfilename') .$querystring_start.'m'.$querystring_equal.$year.zeroise($month, 2).zeroise($day, 2);
    }
    }

    to the following:

    function get_day_link($year, $month, $day) {
    global $querystring_start, $querystring_equal;
    if (!$year) $year = gmdate('Y', time()+(get_settings('gmt_offset') * 3600));
    if (!$month) $month = gmdate('m', time()+(get_settings('gmt_offset') * 3600));
    if (!$day) $day = gmdate('j', time()+(get_settings('gmt_offset') * 3600));
    if ('' != get_settings('permalink_structure')) {
    $off = strpos(get_settings('permalink_structure'), '%day%');
    $offset = $off + 6;
    $daylink = substr(get_settings('permalink_structure'), 0, $offset);
    if ('' != substr($daylink, -1)) $daylink = substr($daylink, 0, -1);
    $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 = str_replace('%post_id%', '', $daylink);
    return get_settings('home') . $daylink;
    } else {
    return get_settings('home') .'/'. get_settings('blogfilename') .$querystring_start.'m'.$querystring_equal.$year.zeroise($month, 2).zeroise($day, 2);
    }
    }

    All I did was get rid of a '/' in the line:

    if ('/' != substr($daylink, -1)) $daylink = substr($daylink, 0, -1);

  3. deadlove
    Member
    Posted 7 years ago #

    Thanks a lot! That seems to fix it. Sorry for the late response!

Topic Closed

This topic has been closed to new replies.

About this Topic