wordpress,使归档页面类别具体

时间:2013-02-01 11:36:38

标签: php wordpress

我编辑了标准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>';

我可以添加到网址吗?像一个查询,以使这3个链接类别具体?似乎没有任何内容可以添加到get_day_link 感谢

1 个答案:

答案 0 :(得分:3)

我还没检查你在做什么,但你可以做的一件事就是创建一个与你的类别相同的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();?>
相关问题