$post-ID
is not the same as $post->ID
. You’re using the former for has_category()
, but the latter for get_the_category()
. $post->ID
is correct.
$post-ID
is not the same as $post->ID
. You’re using the former for has_category()
, but the latter for get_the_category()
. $post->ID
is correct.