get category id by post id in wordpress code example
Example 1: wordpress get post id
// Retrieve the ID of the current item in the WordPress Loop.
get_the_ID()
Example 2: how to get category from post id
get_the_category($post->ID)
// Retrieve the ID of the current item in the WordPress Loop.
get_the_ID()
get_the_category($post->ID)