Commit ca8b2f5
committed
Canonical: Use
This changeset fixes an issue where `wp_get_canonical_url()` always returned `false` for attachments. Attachments have a `inherit` post status rather than `publish`. The `wp_get_canonical_url()` function was directly checking `$post->post_status === 'publish'`, causing it to always return `false` for attachments. Using `get_post_status()` fixes the issue as if the post is an attachment, then the parent post status will be given instead.
Follow-up to [37685].
Props othernoel, ankitkumarshah, SirLouen,
Fixes #63041.
git-svn-id: https://develop.svn.wordpress.org/trunk@60108 602fd350-edb4-49c9-b593-d223f7449a82get_post_status() to determine whether the post has a publish post status in wp_get_canonical_url().1 parent fc1990d commit ca8b2f5
2 files changed
Lines changed: 48 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4063 | 4063 | | |
4064 | 4064 | | |
4065 | 4065 | | |
4066 | | - | |
| 4066 | + | |
4067 | 4067 | | |
4068 | 4068 | | |
4069 | 4069 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
2 | 8 | | |
3 | 9 | | |
| 10 | + | |
| 11 | + | |
4 | 12 | | |
5 | 13 | | |
6 | 14 | | |
7 | 15 | | |
8 | | - | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
9 | 22 | | |
10 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
11 | 36 | | |
12 | 37 | | |
13 | 38 | | |
14 | 39 | | |
15 | 40 | | |
16 | 41 | | |
17 | 42 | | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
18 | 51 | | |
19 | 52 | | |
20 | 53 | | |
| |||
140 | 173 | | |
141 | 174 | | |
142 | 175 | | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
143 | 189 | | |
144 | 190 | | |
145 | 191 | | |
| |||
0 commit comments