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: https://develop.svn.wordpress.org/trunk@13781 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Dion Hulse 2010-03-20 06:27:27 +00:00
parent 9e75e9944d
commit 691bd47301
1 changed files with 5 additions and 0 deletions

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