BLOG2

$categories = get_the_category(); if ( ! empty( $categories ) ) { echo esc_html( $categories[0]->name ); }