簡體   English   中英

wordpress,使存檔頁面類別特定

[英]wordpress, making archive page category specific

我編輯了標准的wordpress日歷,以根據類別突出顯示日期的顏色,日歷功能使用get_day_link()加載當天的所有帖子,但是我想將其限制為僅特定類別。 這是使日期可點擊的鏈接的代碼,這是對general-template.php文件的編輯,函數是get_calendar()

    if  ( in_array($day, $daywithevent) && in_array($day, $daywithtraining) ) // are there both events AND training happening today?
            $calendar_output .= '<td class="training-events-calendar"><a  href="' . get_day_link( $thisyear, $thismonth, $day ) . '" title="' . esc_attr( $ak_titles_for_day[ $day ] ) . "\">$day</a>";
    elseif ( in_array($day, $daywithtraining ) ) // how about just training?
            $calendar_output .= '<td class="training-calendar"><a  href="' . get_day_link( $thisyear, $thismonth, $day ) . "\">$day</a>";
    elseif ( in_array($day, $daywithevent)  ) //how about just events?
            $calendar_output .= '<td class="event-calendar"><a  href="' . get_day_link( $thisyear, $thismonth, $day ) . "\">$day</a>";
    else
        $calendar_output .= '<td>'.$day;
    $calendar_output .= '</td>';

有什么我可以添加到URL的嗎? 像使這3個鏈接類別特定的查詢? 似乎沒有要添加到get_day_link任何內容,謝謝

我還沒有檢查您在做什么,但是您可以做的一件事是創建一個與您的類別相同的date.php文件並運行一個循環,例如

<?php
$query = new WP_Query(array('post_type' => 'post','category__in' => array( 2, 6 ), 'year'=>get_the_date('Y'),'monthnum'=>get_the_date('m'),'day'=>  get_the_date('d')));

 if ($query->have_posts() ) : while ($query->have_posts() ) : $query->the_post();
?>
post details goes here

<?php endwhile; endif; wp_reset_query();?>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM