@@ -972,13 +972,14 @@ function redirect_guess_404_permalink() {
972972 */
973973 $ strict_guess = apply_filters ( 'strict_redirect_guess_404_permalink ' , false );
974974
975- // Build WP_Query arguments.
976975 $ query_args = array (
977- 'post_status ' => $ publicly_viewable_statuses ,
978- 'posts_per_page ' => 1 ,
979- 'no_found_rows ' => true ,
980- 'ignore_sticky_posts ' => true ,
981- 'fields ' => 'ids ' ,
976+ 'post_status ' => $ publicly_viewable_statuses ,
977+ 'posts_per_page ' => 1 ,
978+ 'no_found_rows ' => true ,
979+ 'ignore_sticky_posts ' => true ,
980+ 'update_post_meta_cache ' => false ,
981+ 'update_post_term_cache ' => false ,
982+ 'fields ' => 'ids ' ,
982983 );
983984
984985 // Handle strict vs. loose post_name matching.
@@ -991,7 +992,7 @@ function redirect_guess_404_permalink() {
991992 // Store the filter callback so we can remove it later.
992993 $ post_name_where_filter = function ( $ where , $ query ) use ( $ post_name_for_filter , $ wpdb ) {
993994 // Only apply to our specific query.
994- if ( isset ( $ query ->query_vars ['redirect_guess_404 ' ] ) && $ query -> query_vars [ ' redirect_guess_404 ' ] ) {
995+ if ( isset ( $ query ->query_vars ['redirect_guess_404 ' ] ) ) {
995996 $ where .= $ wpdb ->prepare ( " AND {$ wpdb ->posts }.post_name LIKE %s " , $ wpdb ->esc_like ( $ post_name_for_filter ) . '% ' );
996997 }
997998 return $ where ;
@@ -1036,7 +1037,6 @@ function redirect_guess_404_permalink() {
10361037 $ query_args ['date_query ' ] = array ( $ date_query );
10371038 }
10381039
1039- // Execute the query.
10401040 $ query = new WP_Query ( $ query_args );
10411041
10421042 // Clean up the filter if we added it (remove only our specific callback).
0 commit comments