将发布固定链接添加到发布了帖子的日子

时间:2019-07-16 09:10:56

标签: php wordpress

我创建了一个显示日历的自定义窗口小部件。 下面是打印每月日期的功能:

private function _showDay($cellNumber){

    $query = new WP_Query( $args );


    wp_reset_postdata();

    if( $this->currentDay == 0 ){

        $firstDayOfTheWeek = date('N',strtotime($this->currentYear.'-'.$this->currentMonth.'-01'));

        if( intval( $cellNumber ) == intval($firstDayOfTheWeek)){
            $this->currentDay=1;
        }
    }

    if( ( $this->currentDay != 0 ) && ( $this->currentDay <= $this->daysInMonth ) ){

        $this->currentDate = date('Y-m-d', strtotime($this->currentYear.'-'.$this->currentMonth.'-'.($this->currentDay)));

        $cellContent = $this->currentDay;

        $this->currentDay++;   

    } else {

        $this->currentDate =null;

        $cellContent=null;
    }

    return '<li id="li-'.$this->currentDate.'" class="'.($cellNumber%7==1?' start ':($cellNumber%7==0?' end ':' ')).
            ($cellContent==null?'mask':'').'">'.$cellContent.'</li>';
}

我想更改为以下内容: 从类别事件中获取所有帖子,并且在显示日期时,如果当天有帖子,则每天都需要使用永久链接进行超链接。

我该如何实现?

0 个答案:

没有答案