Opened 18 years ago
Closed 18 years ago
#5781 closed defect (bug) (fixed)
Restore correct permalink for Pages when using post_permalink($post_id)
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | 2.5 | Priority: | normal |
| Severity: | normal | Version: | 2.5 |
| Component: | General | Keywords: | has-patch |
| Focuses: | Cc: |
Description
When using pretty URLs post_permalink($post_id) still returned the /?page_id=xx URL for Pages in -trunk. This was caused by #5607 (committed on 10 Jan 2008) but I believe that was just a symptom of an existing logic bug.
The problem unwound into _get_page_link($id), which expects there to be a global $post available for use. But I could never find a place where that was setup before _get_page_link($id) was being called. Since $id is optional for that function the implication is if no $id was provided then we assume you want to deal with the existing global $post. The reverse of that should also be true, if you do provide an $id that implies that we need to first go fetch the post details before trying to generate the page permalink.
To that end I propose leaving in the change in #5607 and adding the logic that if an $id was provided we call get_post($id) before building the permalink for the page.
(In [6737]) Page permalink fixes from josephscott. fixes #5781