[wp-trac] [WordPress Trac] #36980: get_the_ID () if used outside of a loop returns first post ID
WordPress Trac
noreply at wordpress.org
Tue May 31 11:58:54 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: Posts, Post Types | Version: 4.5.2
Severity: normal | Keywords:
Focuses: |
-------------------------------+-----------------------------
Test,
add var_dump(get_the_ID () );
in archve.php template outside of the loop and it will return first post
from loop ID.
We might need
if (in_the_loop()) {.....
check within the get_the_ID () function
https://developer.wordpress.org/reference/functions/get_the_id/
--
Ticket URL: <https://core.trac.wordpress.org/ticket/36980>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list