HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: /var/www/html/shootinschool/wp-content/themes/splash-child/partials/global/shop-cats.php
<?php
$terms = get_terms( array(
	'taxonomy' => 'product_cat',
	'hide_empty' => false,
	'count' => true,
	'parent' => '0'
) );

$current_obj = get_queried_object();
$current_term_id = 0;

if(!empty($current_obj) and !empty($current_obj->term_id)) {
	$current_term_id = $current_obj->term_id;
}
if ( class_exists( 'WooCommerce' ) ):
	if(!empty($terms) && !is_af()):
	?>
		<div class="stm-shop-categories heading-font">
			<?php foreach($terms as $term): ?>
				<?php
					$active = '';
					if($term->term_id == $current_term_id) {
						$active = 'active';
					}
				?>
				<div class="stm-shop-category">
					<a href="<?php echo esc_url(get_term_link($term)); ?>" class="<?php echo esc_attr($active); ?>">
						<span class="name"><?php echo esc_attr($term->name); ?></span>
						<span class="count">(<?php echo esc_attr($term->count); ?>)</span>
					</a>
				</div>
			<?php endforeach; ?>
		</div>
	<?php endif; ?>
<?php endif; ?>