<?php $terms = get_the_terms(get_the_ID(), 'category'); ?>

<?php if ($terms && ! is_wp_error($terms) && get_theme_mod('single_category', true)) : ?>
	<div class="wp-block-post-terms is-style-colored has-xx-small-font-size">
		<?php foreach ($terms as $term) : ?>
			<a
				class="<?php echo 'category-' . esc_attr($term->slug); ?>"
				href="<?php echo esc_url(get_term_link($term->term_id)); ?>">
				<?php echo esc_html($term->name); ?>
			</a>
		<?php endforeach; ?>
	</div>
<?php endif ?>