WordPress定制日历下一年和前一年给出404

时间:2014-06-17 20:30:25

标签: php wordpress calendar

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

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

我尝试在/之前使用和不使用?year输入正确的网址,但这并不起作用。

这就是我获取数据的方式:

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

1 个答案:

答案 0 :(得分:0)

我使用保留条款进行POST和GET:http://codex.wordpress.org/Function_Reference/register_taxonomy#Reserved_Terms

一旦我将变量更改为passyear并且passget一切都开始工作。

相关问题