EN_PARTS, 'taxonomy' => 'category', 'orderby' => 'ID', 'order' => 'ASC', 'hide_empty' => false ); $categories = get_categories($arg_cat); $current_term = get_queried_object(); // Получаем ID текущей категории или категорий поста $current_term_ids = []; if (is_single()) { $current_term_ids = wp_get_post_categories($current_term->ID); } elseif (is_category()) { $current_term_ids[] = $current_term->term_id; } $firstElement = array_shift($categories); array_push($categories, $firstElement); foreach ($categories ?? [] as $cat) { if ($cat->slug === 'uncategorized') continue; $icon = get_field('icon', 'category_' . $cat->term_id); $bg_image = get_field('bg_image', 'category_' . $cat->term_id); $class = in_array($cat->term_id, $current_term_ids) ? 'is-active' : ''; echo " $cat->name "; }