WordPress.org

Make WordPress Core

Changeset 13781


Ignore:
Timestamp:
03/20/10 06:27:27 (8 years ago)
Author:
dd32
Message:

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

File:
1 edited

Legend:

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

    r13780 r13781  
    165165 
    166166            } 
     167        } elseif ( is_single() && strpos($wp_rewrite->permalink_structure, '%category%') !== false ) { 
     168            $category = get_term_by('slug', get_query_var('category_name'), 'category'); 
     169            $post_terms = wp_get_object_terms($wp_query->get_queried_object_id(), 'category'); 
     170            if ( ! in_array($category, $post_terms) ) 
     171                $redirect_url = get_permalink($wp_query->get_queried_object_id()); 
    167172        } 
    168173 
Note: See TracChangeset for help on using the changeset viewer.