[wp-trac] [WordPress Trac] #36980: get_the_ID () if used outside of a loop returns first post ID

WordPress Trac noreply at wordpress.org
Thu Jun 2 00:45:09 UTC 2016


#36980: get_the_ID () if used outside of a loop returns first post ID
--------------------------+------------------------------
 Reporter:  Themezly      |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Query         |     Version:  4.5.2
 Severity:  normal        |  Resolution:
 Keywords:  close         |     Focuses:
--------------------------+------------------------------
Changes (by dd32):

 * keywords:   => close


Comment:

 Replying to [comment:2 Themezly]:
 > OK understandable but should't  static page id be targeted with
 get_queried_object_id() than?

 That would be the more correct method, yes.
 Unfortunately there's years of code that has been written before those
 functions were available which relies upon the current behaviour, changing
 it isn't viable for backwards-compatible reasons.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/36980#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list