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

WordPress Trac noreply at wordpress.org
Wed Jun 1 19:07:43 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:                |     Focuses:
--------------------------+------------------------------
Changes (by boonebgorges):

 * component:  Posts, Post Types => Query


Comment:

 > but in my opinion if get_the_ID() is caught outside of the loop it
 should not return anything or it should return the get_queried_object_id()
 instead of picking any items from the loop.

 Can you be more specific about what it means to be "outside" of the loop?
 Does the bug happen both before and after the loop?

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


More information about the wp-trac mailing list