diff --git a/wp-includes/canonical.php b/wp-includes/canonical.php index af64d9606..98c3794d4 100644 --- a/wp-includes/canonical.php +++ b/wp-includes/canonical.php @@ -141,8 +141,10 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) { $redirect['query'] = remove_query_arg('year', $redirect['query']); } elseif ( is_author() && !empty($_GET['author']) && preg_match( '|^[0-9]+$|', $_GET['author'] ) ) { $author = get_userdata(get_query_var('author')); - if ( false !== $author && $redirect_url = get_author_posts_url($author->ID, $author->user_nicename) ) - $redirect['query'] = remove_query_arg('author', $redirect['query']); + if ( ( false !== $author ) && $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE $wpdb->posts.post_author = %d AND $wpdb->posts.post_status = 'publish' LIMIT 1", $author->ID ) ) ) { + if ( $redirect_url = get_author_posts_url($author->ID, $author->user_nicename) ) + $redirect['query'] = remove_query_arg('author', $redirect['query']); + } } elseif ( is_category() || is_tag() || is_tax() ) { // Terms (Tags/categories) $term_count = 0;