[wp-trac] [WordPress Trac] #23882: get_permalink() accepts an ID, the_permalink() does not
WordPress Trac
noreply at wordpress.org
Fri Oct 9 10:20:37 UTC 2015
#23882: get_permalink() accepts an ID, the_permalink() does not
-------------------------------------------+------------------------
Reporter: johnjamesjacoby | Owner: chriscct7
Type: enhancement | Status: reopened
Priority: normal | Milestone: 4.4
Component: Permalinks | Version: 3.5
Severity: normal | Resolution:
Keywords: has-patch commit dev-feedback | Focuses:
-------------------------------------------+------------------------
Changes (by Frank Klein):
* keywords: has-patch commit => has-patch commit dev-feedback
* status: closed => reopened
* resolution: fixed =>
Comment:
I'm not sure about this change, and I think it should be reverted, and the
ticket closed as won't fix.
`the_permalink()` is a Template Tag, and as such always needs to be used
in the Loop. It relies on the current global state being set to output the
correct link. Having an ID parameter would change this, and make the
function signature different from the other template tags.
Also currently the function has a `the_permalink` filter. Adding the ID
parameter would change the links that are filtered, as this might be links
to the current post or another post. I'm not sure this won't break
existing code relying on this being the case. Also the filter is not
useful without the parameters passed to the function.
Finally if you are in a template and want to output content that is
different from the one in the loop, you can use the getter functions.
That's a pretty established pattern in WordPress because a lot of template
tags, at least the more recent, exclusively rely on the Loop, and this
change breaks this common pattern.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/23882#comment:8>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list