I work with a function (from a plugin) to display post from a category category group by year, but I can´t filter to category. I try add " $posts = query_posts($query_string . '&cat=3');" but I got all categories. How can I do it? The function:
function favrik_recent_posts($args = '') {
global $wp_locale, $wpdb;
// params fun
parse_str($args, $r);
$defaults = array('group' => '1', 'limit' => '10', 'before' => '<li>', 'after' => '</li>', 'show_post_count' => false, 'show_post_date' => true, 'date' => 'Y', 'order_by' => 'post_date DESC');
$r = array_merge($defaults, $r);
extract($r);
// output
$output = '';
$pre = '';
$full_date = '';
$year = '';
$month = '';
// the query
$where = apply_filters('getarchives_where', "WHERE post_type = 'post' AND post_status = 'publish'");
$join = apply_filters('getarchives_join', "");
$qry = "SELECT ID, post_date, post_title, post_name
FROM $wpdb->posts $join
$where ORDER BY $order_by LIMIT $limit";
$arcresults = $wpdb->get_results($qry);
if ($arcresults) {
foreach ($arcresults as $arcresult) {
if ($arcresult->post_date != '0000-00-00 00:00:00') {
$url = get_permalink($arcresult);
if ($group == 0) { // dates at the side of the post link
$arc_date = date($date, strtotime($arcresult->post_date));
$full_date = '<em class="date">' . $arc_date . '</em> ';
}
if ($group == 1) { // grouping by year then month-day
$y = date('Y', strtotime($arcresult->post_date));
if ($year != $y) {
$year = $y;
$pre = '<li class="year">' . $year . '</li>';
}
/*
$m = date('F Y', strtotime($arcresult->post_date));
if ($month != $m) {
$month = $m;
$pre .= '<li class="month">' . substr($month, 0, -4) . '</li>';
}
*/
}
$text = strip_tags(apply_filters('the_title', $arcresult->post_title));
$output .= get_archives_link($url, $text, $format,
$pre . $before . $full_date,
$after);
$pre = ''; $full_date = '';
}
}
}
echo $output;
}
?>