mirror of
https://github.com/WordPress/WordPress.git
synced 2025-01-09 18:08:09 +01:00
Canonical: Ensure a redirect for posts missing postname
in a query with an ID.
If a site is using `/%post_id%/%postname%/` as permalink structure, and is missing the `postname`, the site won't redirect to the appropriate URL. This change ensure that the redirect happens. Fixes: #12456. Props: Frank.Prendergast, dd32, Otto42, hlanggo, wonderboymusic, atimmer, seth17, calvin_ngan, Niresh12495, anbumz, SergeyBiryukov, donmhico. Built from https://develop.svn.wordpress.org/trunk@47937 git-svn-id: http://core.svn.wordpress.org/trunk@47710 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
f5d5b76f6e
commit
c65334d820
@ -409,6 +409,17 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$redirect['query'] = remove_query_arg( 'page', $redirect['query'] );
|
$redirect['query'] = remove_query_arg( 'page', $redirect['query'] );
|
||||||
|
} elseif ( is_singular() && empty( get_query_var( 'name' ) ) && $post_id ) {
|
||||||
|
/*
|
||||||
|
* Redirect example.org/%post_id%/ to canonical url.
|
||||||
|
* @ticket 12456
|
||||||
|
*/
|
||||||
|
$redirect_url = get_permalink( $post_id );
|
||||||
|
$redirect['query'] = _remove_qs_args_if_not_in_url(
|
||||||
|
$redirect['query'],
|
||||||
|
array( 'p', 'page_id', 'attachment_id', 'pagename', 'name', 'post_type' ),
|
||||||
|
$redirect_url
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Paging and feeds.
|
// Paging and feeds.
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '5.5-alpha-47936';
|
$wp_version = '5.5-alpha-47937';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
Loading…
Reference in New Issue
Block a user