Make WordPress Core


Ignore:
Timestamp:
09/29/2015 04:57:02 AM (9 years ago)
Author:
pento
Message:

Rewrite: Redirect attachment URLs when their slug changes.

Using the same logic that we use to redirect posts when their slug changes, we can provide the same functionality for attachments. Attachment pages are posts, too.

Props swissspdy.

Fixes #34043.

File:
1 edited

Legend:

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

    r34659 r34685  
    47374737
    47384738        // Guess the current post_type based on the query vars.
    4739         if ( get_query_var('post_type') )
    4740             $post_type = get_query_var('post_type');
    4741         elseif ( !empty($wp_query->query_vars['pagename']) )
     4739        if ( get_query_var( 'post_type' ) ) {
     4740            $post_type = get_query_var( 'post_type' );
     4741        } elseif ( get_query_var( 'attachment' ) ) {
     4742            $post_type = 'attachment';
     4743        } elseif ( ! empty( $wp_query->query_vars['pagename'] ) ) {
    47424744            $post_type = 'page';
    4743         else
     4745        } else {
    47444746            $post_type = 'post';
     4747        }
    47454748
    47464749        if ( is_array( $post_type ) ) {
Note: See TracChangeset for help on using the changeset viewer.