ID); } elseif (is_category()) { $current_term_ids[] = $current_term->term_id; } 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); if($bg_image){ $class = in_array($cat->term_id, $current_term_ids) ? 'is-active' : ''; echo " $cat->name "; } }