Changeset 47122 for trunk/src/wp-includes/query.php
- Timestamp:
- 01/29/2020 12:43:23 AM (6 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/query.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/query.php
r47018 r47122 999 999 function wp_old_slug_redirect() { 1000 1000 if ( is_404() && '' !== get_query_var( 'name' ) ) { 1001 // Guess the current post _type based on the query vars.1001 // Guess the current post type based on the query vars. 1002 1002 if ( get_query_var( 'post_type' ) ) { 1003 1003 $post_type = get_query_var( 'post_type' ); … … 1017 1017 } 1018 1018 1019 // Do not attempt redirect for hierarchical post types 1019 // Do not attempt redirect for hierarchical post types. 1020 1020 if ( is_post_type_hierarchical( $post_type ) ) { 1021 1021 return; … … 1062 1062 } 1063 1063 1064 wp_redirect( $link, 301 ); // Permanent redirect 1064 wp_redirect( $link, 301 ); // Permanent redirect. 1065 1065 exit; 1066 1066 } … … 1085 1085 $query = $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta, $wpdb->posts WHERE ID = post_id AND post_type = %s AND meta_key = '_wp_old_slug' AND meta_value = %s", $post_type, get_query_var( 'name' ) ); 1086 1086 1087 // if year, monthnum, or day have been specified, make our query more precise1088 // just in case there are multiple identical _wp_old_slug values 1087 // If year, monthnum, or day have been specified, make our query more precise 1088 // just in case there are multiple identical _wp_old_slug values. 1089 1089 if ( get_query_var( 'year' ) ) { 1090 1090 $query .= $wpdb->prepare( ' AND YEAR(post_date) = %d', get_query_var( 'year' ) ); … … 1134 1134 1135 1135 if ( ! $id ) { 1136 // Check to see if an old slug matches the old date 1136 // Check to see if an old slug matches the old date. 1137 1137 $id = (int) $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts, $wpdb->postmeta AS pm_slug, $wpdb->postmeta AS pm_date WHERE ID = pm_slug.post_id AND ID = pm_date.post_id AND post_type = %s AND pm_slug.meta_key = '_wp_old_slug' AND pm_slug.meta_value = %s AND pm_date.meta_key = '_wp_old_date'" . $date_query, $post_type, get_query_var( 'name' ) ) ); 1138 1138 }
Note: See TracChangeset
for help on using the changeset viewer.