[wp-trac] [WordPress Trac] #40562: get_permalink($id) and get_permalink($id) get_post_permalink ($id) Return current page Url, not Url of requested ID

WordPress Trac noreply at wordpress.org
Tue Apr 25 14:32:35 UTC 2017


#40562: get_permalink($id)  and get_permalink($id) get_post_permalink ($id) Return
current page Url, not Url of requested ID
--------------------------+------------------------------
 Reporter:  thefraj       |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  General       |     Version:  4.7.4
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:
--------------------------+------------------------------

Comment (by bhargavbhandari90):

 Hi there,
 `get_post_permalink` will give result only for custom post types. Try to
 check if you are passing the CPT's id.

 Replying to [comment:1 thefraj]:
 > Sorry, the title should have read:
 >
 > get_post_permalink($id) and get_permalink($id) this bug affects both of
 these methods where it is not possible to obtain a Url of the requested
 page or post Id
 >
 > Replying to [ticket:40562 thefraj]:
 > > If I had a page (say) ID = 4 and then did:
 > >
 > > <a href="<?php echo get_post_permalink(4); ?>">the link</a>
 > >
 > > this will return the link to the current page, not the link of page ID
 = 4
 > >
 > > Your documentation suggests it would return the Url of page ID = 4 as
 detailed here
 https://developer.wordpress.org/reference/functions/get_post_permalink/
 > >
 > >

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


More information about the wp-trac mailing list