get post id code example
Example 1: how to get category from post id
get_the_category($post->ID)
Example 2: get_the_id wordpress
function get_the_ID() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
$post = get_post();
return ! empty( $post ) ? $post->ID : false;
}
Example 3: get wordpress id
echo get_the_ID();
Example 4: get term id by post id
INSIDE TAXONOMY PAGES
$term = get_queried_object();
$term_id = $term->term_id;