[wp-trac] [WordPress Trac] #19012: get_ID and the_ID should accept $id as a parameter

WordPress Trac wp-trac at lists.automattic.com
Thu Oct 20 15:10:41 UTC 2011

#19012: get_ID and the_ID should accept $id as a parameter
 Reporter:  peterchester                         |       Owner:  ryan
     Type:  enhancement                          |      Status:  reviewing
 Priority:  normal                               |   Milestone:  Future
Component:  Post Types                           |  Release
 Severity:  normal                               |     Version:  3.3
 Keywords:  needs-testing needs-codex has-patch  |  Resolution:

Comment (by nacin):

 One PHP5 option is:

 `$post_id = get_post( $post_id )->ID;`

 That'll work with null, an ID, or even a post object being passed.

 I think this is a bit clearer than get_the_ID() being able to take an ID
 parameter, which seems really confusing.

 In many cases, we have functions that do these checks instead of just
 passing null etc. further down the stack, which is appropriate sometimes.
 One example is has_post_thumbnail(), which could simply pass null to

Ticket URL: <http://core.trac.wordpress.org/ticket/19012#comment:9>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software

More information about the wp-trac mailing list