Nije tako jednostavno, evo napisao sam jedan mini-plugin koji resava problem (samo se ubaci u functions), pa ako nekom treba slobodno ga koristite:
PHP kôd:
/**
* Allows you to include and/or exclude posts by category from wp_get_archives() call
* @author Ivan Dilber (http://dilber.info)
* @copyright Copyright (c) 2011, Ivan Dilber
* @license http://creativecommons.org/licenses/by/3.0/
*
* Usage:
* - Add the code below to the functions.php file (in you theme's folder)
* - Use wp_get_archives() as usual. You now have an additional param 'cat', that
* can be used to include/exclude one or more categories by ID. Negative value excludes
* the ID, positive includes only it (and you can mix the negative and positive values)
* Example:
* - wp_get_archives('cat=-1,-2,3'); // exclude categories 1 and 2, include 3
* - wp_get_archives(array('show_post_count=1&cat=4'); //you can combine params
* - wp_get_archives(array('cat' => 4)); //another way to pass params
*/
/**
* Register some hooks
*/
add_filter('getarchives_where', 'ivan_set_archives_where', 10, 2);
add_filter('getarchives_join', 'ivan_set_archives_join', 10, 0);
/**
* WP Filter: Adds categories to the wp_get_archives() query
* @author Ivan Dilber (http://dilber.info)
*/
function ivan_set_archives_join() {
global $wpdb;
return " INNER JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id) INNER JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)";
}
/**
* WP Filter: Change where condition to filter by category ID
* @author Ivan Dilber (http://dilber.info)
*/
function ivan_set_archives_where($where, $args) {
global $wpdb;
if(empty($args['cat'])) // don't alter the query
return $where;
$cats = is_numeric($args['cat'])? array($args['cat']) : explode(',', $args['cat']);
$in = $not_in = array();
foreach($cats as $cat_id) {
if($cat_id < 0)
$not_in[] = -1 * $cat_id;
else
$in[] = (int) $cat_id;
}
$sql = $where ." AND $wpdb->term_taxonomy.taxonomy='category'";
if($in)
$sql .= sprintf(" AND $wpdb->term_taxonomy.term_id IN (%s)", implode(', ', $in));
if($not_in)
$sql .= sprintf(" AND $wpdb->term_taxonomy.term_id NOT IN (%s)", implode(', ', $not_in));
return $sql;
}
Ukoliko neko ovo bude koristio u temama pls. ostavite copyright info, nije da cu ja to da proveravam, ali ipak...