[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:16:07 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:
--------------------------+------------------------------

Comment (by Themezly):

 Yes , it is  both before and after the loop we get first or last item from
 the loop ,

 if you just place print_r  on top of the archive.php  you get first item
 from loop ID,
 thus it made no sense since if out of the loop than the archive is main
 not any of the items from the loop.
 Here is the reference
 https://github.com/ThemeFuse/Unyson/issues/1582#issuecomment-222519762

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


More information about the wp-trac mailing list