mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-22 17:18:32 +01:00
Attempt canonical redirect only for public post types. Props solarissmoke. see #13125
git-svn-id: http://svn.automattic.com/wordpress/trunk@14595 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
44de0d4ff9
commit
ef81c17d3e
@ -83,9 +83,14 @@ function redirect_canonical($requested_url=null, $do_redirect=true) {
|
|||||||
if ( is_404() ) {
|
if ( is_404() ) {
|
||||||
|
|
||||||
// Redirect ?page_id, ?p=, ?attachment_id= to their respective url's
|
// Redirect ?page_id, ?p=, ?attachment_id= to their respective url's
|
||||||
$id = max( get_query_var('p'), get_query_var('page_id'), get_query_var('attachment_id'));
|
$id = max( get_query_var('p'), get_query_var('page_id'), get_query_var('attachment_id') );
|
||||||
if ( $id && $redirect_url = get_permalink($id) )
|
if ( $id && $redirect_post = get_post($id) ) {
|
||||||
$redirect['query'] = remove_query_arg(array('p', 'page_id', 'attachment_id'), $redirect['query']);
|
$post_type_obj = get_post_type_object($redirect_post->post_type);
|
||||||
|
if ( $post_type_obj->public ) {
|
||||||
|
$redirect_url = get_permalink($redirect_post);
|
||||||
|
$redirect['query'] = remove_query_arg(array('p', 'page_id', 'attachment_id'), $redirect['query']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( ! $redirect_url )
|
if ( ! $redirect_url )
|
||||||
$redirect_url = redirect_guess_404_permalink();
|
$redirect_url = redirect_guess_404_permalink();
|
||||||
|
Loading…
Reference in New Issue
Block a user