What is the difference between $post_id and get_the_ID()?
get_the_ID() returns the ID of the current post by way of get_post. Get post assumes the current post to be the global variable $post unless passed parameters specifying otherwise. That means that get_the_ID() should return the same value as contained in $post->ID. Using get_the_ID() lets you avoid dealing with the global directly, though you are … Read more