1.functions.phpに下記のコードを追加します
function cat_limited_wp_get_archives( $where ) { global $wpdb; $cat_string = '3,4,5'; $where .= " AND $wpdb->posts.ID NOT IN ( SELECT tr.object_id FROM $wpdb->term_relationships AS tr INNER JOIN $wpdb->term_taxonomy AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy = 'category' AND tt.term_id IN ($cat_string) )"; return $where; } add_filter( 'getarchives_where', 'cat_limited_wp_get_archives' );
$cat_string = ‘3,4,5’; // 除外したいカテゴリーIDを記入します。
2.テンプレートの表示したい場所に下記を追加すればOK!
<ul> <li><?php wp_get_archives('type=monthly'); ?></li> </ul>