Only allow %category% to be a valid category attached to the current post when using %category% in a permalink structure. Fixes #11807

git-svn-id: http://svn.automattic.com/wordpress/trunk@13781 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
dd32 2010-03-20 06:27:27 +00:00
parent f90f47a073
commit b6e3b188e7

View File

@ -164,6 +164,11 @@ function redirect_canonical($requested_url=null, $do_redirect=true) {
}
}
} elseif ( is_single() && strpos($wp_rewrite->permalink_structure, '%category%') !== false ) {
$category = get_term_by('slug', get_query_var('category_name'), 'category');
$post_terms = wp_get_object_terms($wp_query->get_queried_object_id(), 'category');
if ( ! in_array($category, $post_terms) )
$redirect_url = get_permalink($wp_query->get_queried_object_id());
}
// paging and feeds