下一年和下一年的WordPress定制日历提供404 [英] WordPress customized calendar next and previous year gives 404

查看:89
本文介绍了下一年和下一年的WordPress定制日历提供404的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用WordPress创建的日历。顶部有下一个和上个月的链接。他们可以顺利浏览当前年份,但是当年份更改为下一年或上一年时,我会收到404错误。

I have a calendar that I created in WordPress. There is a next and previous month link at the top. They navigate fine through the current year, but when the year changes to either the next or previous year, I get a 404 error.

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

The link with each month looks like this (January 2014 for example): mysiteurl.com/calendar-grid/?year=2014&month=1

我尝试只在?year 之前输入正确的URL,带和不带 / ,但这不是工作。

I have tried just typing in the correct url with and without the / before the ?year and that doesn't work.

这是我获取数据的方式:

This is how I am getting the data:

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

here is the link for December 2014: http://houseof.mspaceap.com/calendar-grid/?year=2014&month=12

推荐答案

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

I was using reserved terms for POST and GET: http://codex.wordpress.org/Function_Reference/register_taxonomy#Reserved_Terms

我将变量更改为passyear并通过密码开始一切工作。

Once I changed the variables to passyear and passget everything started working.

这篇关于下一年和下一年的WordPress定制日历提供404的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆