試試這個:
add_filter('getarchives_where', 'get_archives_where', 10, 2);
add_filter('getarchives_join', 'get_archives_join', 10, 2);
wp_get_archives(array('type' => 'monthly')); //put your parameters
remove_filter('getarchives_where', 'get_archives_where');
remove_filter('getarchives_join', 'get_archives_join');
function get_archives_where($where, $r){
global $wpdb;
$where .= " AND ". $wpdb->prefix. "terms.slug = 'blog-post' AND ". $wpdb->prefix. "term_taxonomy.taxonomy = 'category'";
return $where;
}
function get_archives_join($join, $r){
global $wpdb;
$join = "inner join ". $wpdb->prefix . "term_relationships on ". $wpdb->prefix . "posts.ID = ". $wpdb->prefix . "term_relationships.object_id inner join ". $wpdb->prefix . "term_taxonomy on ". $wpdb->prefix . "term_relationships.term_taxonomy_id = ". $wpdb->prefix . "term_taxonomy.term_taxonomy_id inner join ". $wpdb->prefix . "terms on ". $wpdb->prefix . "term_taxonomy.term_id = ". $wpdb->prefix . "terms.term_id";
return $join;
}
是https://wordpress.stackexchange.com/questions/95776/how-we-display-archives-for-specific-categories作品。我剛剛以更合適的方式呈現了它。
我還發現這個http://wordpress.org/plugins/wp-category-archive的部件。這也可能有助於一些(但是,這個插件是非常舊的)
http://wordpress.stackexchange.com/questions/95776/how-we-display-archives-for-specific-categories – Dipak
我得到了我的答案在這個鏈接謝謝你! – Dipak