[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 05:55:42 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 needs-     |  Resolution:
  patch 2nd-opinion                              |
-------------------------------------------------+-------------------------

Comment (by peterchester):

 Hi scribu! Actually, I just posted an example in my previous comment.

 The problem is that the wordpress code (as well as just about every
 template and plugin that i've ever encountered) is riddled with phrases
 that go like this:

 {{{
 function my_function( $post_id = null ) {
         $post_id = ( null === $post_id ) ? get_the_ID() : $post_id;
         ....
 }
 }}}

 I'm proposing that we could help this along by simply passing through the
 post id if it's set.

 {{{
 function my_function( $post_id = null ) {
         $post_id = get_the_ID( $post_id );
         ....
 }
 }}}

 This way, if $post_id was not set, then it's returned contextually, if it
 is, then it's just passed through.

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


More information about the wp-trac mailing list