| 1 | Index: wp-includes/canonical.php |
|---|
| 2 | =================================================================== |
|---|
| 3 | --- wp-includes/canonical.php (revision 19955) |
|---|
| 4 | +++ wp-includes/canonical.php (working copy) |
|---|
| 5 | @@ -96,6 +96,11 @@ |
|---|
| 6 | $redirect_url = redirect_guess_404_permalink( $requested_url ); |
|---|
| 7 | |
|---|
| 8 | } elseif ( is_object($wp_rewrite) && $wp_rewrite->using_permalinks() ) { |
|---|
| 9 | + // make sure attachments have the right parent, see #19918 |
|---|
| 10 | + if( is_attachment() && ! $redirect_url ) { |
|---|
| 11 | + $redirect_url = get_attachment_link( get_query_var( 'attachment_id' ) ); |
|---|
| 12 | + } |
|---|
| 13 | + |
|---|
| 14 | // rewriting of old ?p=X, ?m=2004, ?m=200401, ?m=20040101 |
|---|
| 15 | if ( is_attachment() && !empty($_GET['attachment_id']) && ! $redirect_url ) { |
|---|
| 16 | if ( $redirect_url = get_attachment_link(get_query_var('attachment_id')) ) |
|---|