not visibled category = 7
This commit is contained in:
@@ -1269,6 +1269,28 @@ function replace_first_figure_in_content($content) {
|
|||||||
return $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);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user