点击日历按钮更改网址

时间:2019-03-19 18:07:09

标签: php wordpress url calendar

我是Web编码的新手,尝试使用WordPress的日历插件,找到并修改了日历以使其适合我的工作方式。但是,现在当我单击按钮+/-月/年时,总会更改我的URL(即直接从我的WP)。有办法解决吗?

这些按钮的代码是:

要设置功能:

// Jump to last month
function monthBack( $timestamp ){
    return mktime(0,0,0, date("m",$timestamp)-1,date("d",$timestamp),date("Y",$timestamp) );
}

// Jump to last year
function yearBack( $timestamp ){
    return mktime(0,0,0, date("m",$timestamp),date("d",$timestamp),date("Y",$timestamp)-1 );
}

// Jump to next month
function monthForward( $timestamp ){
    return mktime(0,0,0, date("m",$timestamp)+1,date("d",$timestamp),date("Y",$timestamp) );
}

// Jump to next year
function yearForward( $timestamp ){
    return mktime(0,0,0, date("m",$timestamp),date("d",$timestamp),date("Y",$timestamp)+1 );
}  
  

这是日历的代码

要实现它们:

// If there is a timestamp -> set date to current timestamp
if( isset($_REQUEST['timestamp'])) $date = $_REQUEST['timestamp'];
// If not get new timestamp
else $date = time();

<div class="calender" id="chocToggle">
    <div class="pagination">
        <!-- Creates buttons for earlier defined maneuvering functions -->
        <a href="?timestamp=<?php echo yearBack($date); ?>" class="last">|&laquo;</a> 
        <a href="?timestamp=<?php echo monthBack($date); ?>" class="last">&laquo;</a> 
        <!-- Head to put out current month and year -->
        <div class="pagihead">
        <span><?php echo $arrMonth[date('F',$date)];?> <?php echo date('Y',$date); ?></span>
        </div>
        <!-- Creates buttons for earlier defined maneuvering functions -->
        <a href="?timestamp=<?php echo monthForward($date); ?>" class="next">&raquo;</a>
        <a href="?timestamp=<?php echo yearForward($date); ?>" class="next">&raquo;|</a>  
    </div>
    <!-- Creates the calendar -->
    <?php getCalender($date,$headline); ?>
    <!-- Makes sure there's no floating elements on the left side -->
    <div class="clear"></div>
</div>

结果如下:

  

http://localhost/mysite/wp-admin/admin.php?timestamp=1555632000

代替

  

http://localhost/mysite/wp-admin/admin.php?page=chocolate-calendar%2Fchocolate-calendar.php

0 个答案:

没有答案