Opened 19 years ago
Closed 19 years ago
#5781 closed defect (bug) (fixed)
Restore correct permalink for Pages when using post_permalink($post_id)
| Reported by: | josephscott | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | 2.5 |
| Component: | General | Version: | 2.5 |
| Severity: | normal | Keywords: | has-patch |
| Cc: | Focuses: |
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.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
(In [6737]) Page permalink fixes from josephscott. fixes #5781