get the category skug code example
Example 1: wordpress get post category name
<?php
$categories = get_the_category();
if ( ! empty( $categories ) ) {
echo esc_html( $categories[0]->name ); // Show first item of category
}
?>
Example 2: wordpress display post categories
<?php the_terms( $post->ID, 'topics', 'Topics: ', ', ', ' ' ); ?>