From 170ce9119429b7c3e90b3c29f8ed0d2f13fc8efc Mon Sep 17 00:00:00 2001 From: markjaquith Date: Sat, 7 Apr 2012 05:39:08 +0000 Subject: [PATCH] Handle page= and feed= query strings in redirect_guess_404_permalink(). fixes #20387 git-svn-id: http://svn.automattic.com/wordpress/trunk@20398 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/canonical.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/wp-includes/canonical.php b/wp-includes/canonical.php index e0881ad09..dbcf07e87 100644 --- a/wp-includes/canonical.php +++ b/wp-includes/canonical.php @@ -101,7 +101,7 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) { if ( ! $redirect_url ) { if ( $redirect_url = redirect_guess_404_permalink( $requested_url ) ) { - $redirect['query'] = _remove_qs_args_if_not_in_url( $redirect['query'], array( 'p', 'page_id', 'attachment_id', 'pagename', 'name', 'post_type' ), $redirect_url ); + $redirect['query'] = _remove_qs_args_if_not_in_url( $redirect['query'], array( 'page', 'feed', 'p', 'page_id', 'attachment_id', 'pagename', 'name', 'post_type' ), $redirect_url ); } } @@ -489,7 +489,12 @@ function redirect_guess_404_permalink( $current_url = '' ) { $post_id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE $where AND post_status = 'publish'"); if ( ! $post_id ) return false; - return get_permalink( $post_id ); + if ( get_query_var( 'feed' ) ) + return get_post_comments_feed_link( $post_id, get_query_var( 'feed' ) ); + elseif ( get_query_var( 'page' ) ) + return trailingslashit( get_permalink( $post_id ) ) . user_trailingslashit( get_query_var( 'page' ), 'single_paged' ); + else + return get_permalink( $post_id ); } return false;