WordPress自定义日历明年和前一年给出404


WordPress customized calendar next and previous year gives 404

我在WordPress中创建了一个日历。在顶部有一个下一个月和上一个月的链接。它们可以很好地导航到当前年份,但是当年份更改为下一年或前一年时,我得到404错误。

每个月的链接如下(以2014年1月为例):mysiteurl.com/calendar-grid/?year=2014&month=1

我试过在?year之前输入正确的url,有和没有/,这不起作用。

我是这样得到数据的:

if($_GET['month'] == ''){
    $currmonth = date('n');
    $thisyear = date('Y');
}
else {
    $currmonth = $_GET['month'];
    $thisyear = $_GET['year'];
}
$thismonth = paddNum($currmonth);
$firstday = $thisyear.$thismonth.'01';
$lastday = date('Ymt', strtotime($firstday));
$numdays = $lastday - $firstday + 1;
$firstDOW = date('N', strtotime($thisyear.'/'.$thismonth.'/01')) + 1;
if($firstDOW == 8) $firstDOW = 1;
$nextmonth = $thismonth + 1;
$prevmonth = $thismonth - 1;
$nextyear = $thisyear;
$prevyear = $thisyear;
if($nextmonth == 13){
    $nextmonth = 1;
    $nextyear = $thisyear + 1;
}
elseif($prevmonth == 0){
    $prevmonth = 12;
    $prevyear = $thisyear - 1;
}
$args = array(
    'post_type' => 'event',
    'meta_query' => array(
        array(
            'key'       => 'event_date',
            'compare'   => 'BETWEEN',
            'value'     => array($firstday, $lastday)
        )
    ),
    'posts_per_page' => -1
);
$posts = get_posts($args);

链接是这样创建的:

<div class="month-head-text">
    <a class="month-prev" href="<?php echo get_home_url(); ?>/calendar-grid?year=<?php echo $prevyear; ?>&month=<?php echo $prevmonth; ?>">
        <img src="<?php echo get_template_directory_uri(); ?>/images/prev-month.png" />
    </a>
    <div class="month-name"><?php echo translateMonth($thismonth); ?></div>
    <a class="month-next" href="<?php echo get_home_url(); ?>/calendar-grid?year=<?php echo $nextyear; ?>&month=<?php echo $nextmonth; ?>">
        <img src="<?php echo get_template_directory_uri(); ?>/images/next-month.png" />
    </a>
    <a class="close-cal" href="<?php echo get_home_url(); ?>/calendar"><img src="<?php echo get_template_directory_uri(); ?>/images/close.png" /></a>
</div>

这里是2014年12月的链接:http://houseof.mspaceap.com/calendar-grid/?year=2014&month=12

我为POST和GET使用保留术语:http://codex.wordpress.org/Function_Reference/register_taxonomy#Reserved_Terms

一旦我把变量改为passyear和passget,一切都开始工作了