WordPress.org

Make WordPress Core


Ignore:
Timestamp:
09/29/2015 09:41:14 AM (6 years ago)
Author:
pento
Message:

Permalinks: Add pretty permalinks for unattached attachments.

Previously, unattached attachments would have unsightly /?attachment_id=1 URLs. As we've moved away from attachments being specifically attached to posts, instead being Media items, this has made the unattached URLs a more common occurrence.

We can breath easy once more, knowing that the world is a little bit safer from the horror of unnecessarily ugly URLs.

Props SergeyBiryukov, wonderboymusic, pento.

Fixes #1914.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/query.php

    r34685 r34690  
    35813581        if ( !empty($this->posts) && ($this->is_single || $this->is_page) ) {
    35823582            $status = get_post_status($this->posts[0]);
     3583            if ( 'attachment' === $this->posts[0]->post_type && 0 === (int) $this->posts[0]->post_parent ) {
     3584                $this->is_page = false;
     3585                $this->is_single = true;
     3586                $this->is_attachment = true;
     3587            }
    35833588            $post_status_obj = get_post_status_object($status);
    35843589            //$type = get_post_type($this->posts[0]);
Note: See TracChangeset for help on using the changeset viewer.