wordpress get category from post id code example
Example 1: how to get category from post id
get_the_category($post->ID)
Example 2: wordpress get post category name
<?php
$categories = get_the_category();
if ( ! empty( $categories ) ) {
echo esc_html( $categories[0]->name ); // Show first item of category
}
?>