[wp-trac] [WordPress Trac] #23882: get_permalink() accepts an ID, the_permalink() does not

WordPress Trac noreply at wordpress.org
Fri Oct 9 10:50:16 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:
-------------------------------------------+------------------------

Comment (by chriscct7):

 Replying to [comment:8 Frank Klein]:
 > 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.

 the_permalink is simply a wrapper for get_permalink()
 > 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.

 The ID parameter only changes the functionality of the function if you use
 it, which would be new, and thus non breaking. Using the ID parameter in
 get_permalink is the same way. Added a patch to add the parameter

 There's nothing in this patch that changes any existing behavior, it
 simply adds new functionality (similar to adding additional arguments to
 the WP_Query).

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


More information about the wp-trac mailing list