That’s because object properties are case sensitive, thus $post->ID
is not the same as $post->id
.
Just by printing out these two you’ll notice the difference, or do a print_r of the $post
object to see all of the available properties and methods.