WordPress Get Post Category Name

<?php
$categories = get_the_category();

if ( ! empty( $categories ) ) {
 echo esc_html( $categories[0]->name ); // Show first item of category
}
?>

Leave a Comment