Canonical: redirect URLs that match an attachment masked on the wrong URL to the attachment link for the matched attachment.
Props solarissmoke. Fixes #19918. git-svn-id: https://develop.svn.wordpress.org/trunk@34272 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
73c1ac8b26
commit
2a4eba2eb8
@ -150,9 +150,15 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) {
|
||||
|
||||
} elseif ( is_object($wp_rewrite) && $wp_rewrite->using_permalinks() ) {
|
||||
// rewriting of old ?p=X, ?m=2004, ?m=200401, ?m=20040101
|
||||
if ( is_attachment() && !empty($_GET['attachment_id']) && ! $redirect_url ) {
|
||||
if ( $redirect_url = get_attachment_link(get_query_var('attachment_id')) )
|
||||
$redirect['query'] = remove_query_arg('attachment_id', $redirect['query']);
|
||||
if ( is_attachment() && ! $redirect_url ) {
|
||||
if ( ! empty( $_GET['attachment_id'] ) ) {
|
||||
$redirect_url = get_attachment_link( get_query_var( 'attachment_id' ) );
|
||||
if ( $redirect_url ) {
|
||||
$redirect['query'] = remove_query_arg( 'attachment_id', $redirect['query'] );
|
||||
}
|
||||
} else {
|
||||
$redirect_url = get_attachment_link();
|
||||
}
|
||||
} elseif ( is_single() && !empty($_GET['p']) && ! $redirect_url ) {
|
||||
if ( $redirect_url = get_permalink(get_query_var('p')) )
|
||||
$redirect['query'] = remove_query_arg(array('p', 'post_type'), $redirect['query']);
|
||||
|
Loading…
Reference in New Issue
Block a user