0
我有一個我在WordPress中創建的日曆。頂部有一個下一個和上個月的鏈接。他們在今年的時間裏都很順利,但是當年份更改爲下一年或上一年時,我會遇到404錯誤。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