WordPress.org

Make WordPress Core

Changeset 15848


Ignore:
Timestamp:
10/19/10 10:27:34 (4 years ago)
Author:
dd32
Message:

Limit wp_old_slug_redirect() to redirecting to only posts of the same post_type kind. See #15140

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/query.php

    r15843 r15848  
    31473147        global $wpdb; 
    31483148 
    3149         $query = $wpdb->prepare("SELECT post_id FROM $wpdb->postmeta, $wpdb->posts WHERE ID = post_id AND meta_key = '_wp_old_slug' AND meta_value=%s", $wp_query->query_vars['name']); 
     3149        // Guess the current post_type based on the query vars. 
     3150        if ( get_query_var('post_type') ) 
     3151            $post_type = get_query_var('post_type'); 
     3152        elseif ( !empty($wp_query->query_vars['pagename']) ) 
     3153            $post_type = 'page'; 
     3154        else 
     3155            $post_type = 'post'; 
     3156 
     3157        $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, $wp_query->query_vars['name']); 
    31503158 
    31513159        // if year, monthnum, or day have been specified, make our query more precise 
Note: See TracChangeset for help on using the changeset viewer.