• Resolved deadlove

    (@deadlove)


    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:

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

    it will be broken. But if I type in

    https://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 (https://www.binarymoon.co.uk/projects/regulus/) and my permalink structure is date and name based. Thanks for any help you are able to provide!

Viewing 2 replies - 1 through 2 (of 2 total)
  • 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);

    Thread Starter deadlove

    (@deadlove)

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

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Broken calendar links’ is closed to new replies.