Make WordPress Core


Ignore:
Timestamp:
03/30/2025 11:32:38 PM (3 months ago)
Author:
audrasjb
Message:

Canonical: Use get_post_status() to determine whether the post has a publish post status in wp_get_canonical_url().

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
Note: See TracChangeset for help on using the changeset viewer.