0

標準のワードプレスカレンダーを編集して、カテゴリに基づいて日の色を強調表示しました。カレンダー機能は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 感謝に追加するものは何もないようです

4

1 に答える 1

3

私はあなたが何をしているのかを確認していませんが、できることの1つは、カテゴリと同じ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();?>
于 2013-02-01T12:06:32.513 に答える