From c2ab20273c7f3505a132fe5e387368b6cbc896a7 Mon Sep 17 00:00:00 2001 From: argoexpert press Date: Mon, 12 May 2025 11:47:09 +0300 Subject: [PATCH] not visibled category = 7 --- functions.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/functions.php b/functions.php index 3586958..47f3e28 100644 --- a/functions.php +++ b/functions.php @@ -1269,6 +1269,28 @@ function replace_first_figure_in_content($content) { return $content; } +/** + * убираем рубрики - Смена (7) + */ + +// Для стандартного метабокса (классический редактор и часть Гутенберга) +add_filter('get_terms', function($terms, $taxonomies, $args) { + global $pagenow; + if (($pagenow === 'post.php' || $pagenow === 'post-new.php') && in_array('category', $taxonomies)) { + $exclude_ids = [7]; // ID рубрик, которые нужно скрыть + $terms = array_filter($terms, fn($term) => !in_array($term->term_id, $exclude_ids)); + } + return $terms; +}, 10, 3); + +// Для REST API (панель справа в редакторе Gutenberg) +add_filter('rest_category_query', function($args, $request) { + $args['exclude'] = [7]; // Те же ID, что и выше + return $args; +}, 10, 2); + + +