get_the_category retrieve array of post categories.
This tag may be used outside the loop by passing a post id
as the parameter.
The syntax is
$categories = get_the_category( $post_id ); // Outside the loop
// OR
$categories = get_the_category( ); // Inside the loop
Note: This function only returns results from the default “category” taxonomy. For custom taxonomies use get_the_terms() .
$categories = get_the_terms( $post_id, 'taxonomy' );
I hope this may help.