Adrian
Adrian

Reputation: 2012

wordpress, making archive page category specific

I edited the standard wordpress calendar to highlight the colours of days based on the category, the calendar functionality uses get_day_link() which loads ALL posts on that day, however I want to restrict this to just particular categories. Here is the code that makes the days clickable links, this is an edit of the general-template.php file , the function is 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>';

Is there anything I could add to to the url? like a query to make these 3 links category specific? There doesnt seem to be anything to add to get_day_link Thanks

Upvotes: 0

Views: 177

Answers (1)

anstrangel0ver
anstrangel0ver

Reputation: 1073

i havent check what you are doing but 1 thing you can do is create a date.php file same as your category and run a loop like

<?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();?>

Upvotes: 3

Related Questions