WordPress.org

Make WordPress Core

Ticket #19918: 19918.diff

File 19918.diff, 778 bytes (added by solarissmoke, 2 years ago)
  • wp-includes/canonical.php

     
    9696                        $redirect_url = redirect_guess_404_permalink( $requested_url ); 
    9797 
    9898        } elseif ( is_object($wp_rewrite) && $wp_rewrite->using_permalinks() ) { 
     99                // make sure attachments have the right parent, see #19918 
     100                if( is_attachment() && ! $redirect_url  ) { 
     101                        $redirect_url = get_attachment_link( get_query_var( 'attachment_id' ) ); 
     102                } 
     103                 
    99104                // rewriting of old ?p=X, ?m=2004, ?m=200401, ?m=20040101 
    100105                if ( is_attachment() && !empty($_GET['attachment_id']) && ! $redirect_url ) { 
    101106                        if ( $redirect_url = get_attachment_link(get_query_var('attachment_id')) )