i also tried
define("EXCLUDED_CATEGORIES", '25,55,57');
add_filter( 'getarchives_join' , 'getarchives_join_filter');
function getarchives_join_filter( $join ) {
global $wpdb;
return $join . " INNER JOIN {$wpdb->term_relationships} tr ON ($wpdb->posts.ID = tr.object_id) INNER JOIN {$wpdb->term_taxonomy} tt ON (tr.term_taxonomy_id = tt.term_taxonomy_id)";
}
add_filter( 'getarchives_where' , 'getarchives_where_filter');
function getarchives_where_filter( $where ) {
global $wpdb;
$exclude = EXCLUDED_CATEGORIES; // category ids to exclude
return $where . " AND tt.taxonomy = 'category' AND tt.term_id NOT IN ($exclude)";
}
// exclude categories on monthly archive pages
function my_post_queries( $query ) {
// do not alter the query on wp-admin pages and only alter it if it's the main query
if (!is_admin() && $query->is_main_query()){
// alter the query for monthly archive pages
if(is_archive() && is_month()){
$query->set('category__not_in', array(EXCLUDED_CATEGORIES));
}
}
}
add_action( 'pre_get_posts', 'my_post_queries' );
[Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum’s parser.]
but this exclude only the first cat_id, for example if i have ‘1,3,8’ it will exclude only cat_id=1. How i can fix this?