To remove categories from the archive & categories widget in sidebar use following code (functions.php):-
/* exclude categories from category widget */
add_filter("widget_categories_args","exclude_widget_categories");
function exclude_widget_categories( $args ){
$args["exclude"] = '7'; //multiple = '7,8,9' using IDs from Posts=>Categories page in admin
return $args;
}
/* exclude categories from archive list widget */
add_filter('getarchives_join','customarchives_join');
add_filter('getarchives_where','customarchives_where');
function customarchives_join($x) {
global $wpdb;
return $x." 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)";
}
function customarchives_where($x) {
global $wpdb;
$exclude='7'; //multiple = '7,8,9' using IDs from Posts=>Categories page in admin
return $x." AND $wpdb->term_taxonomy.taxonomy = 'category' AND $wpdb->term_taxonomy.term_id NOT IN ($exclude)";
}