[wp-trac] [WordPress Trac] #18734: Subcategory archive does work with any name as parent category in URL

WordPress Trac noreply at wordpress.org
Mon Oct 22 23:10:00 UTC 2012


#18734: Subcategory archive does work with any name as parent category in URL
------------------------------------------+-----------------------------
 Reporter:  ocean90                       |       Owner:
     Type:  defect (bug)                  |      Status:  new
 Priority:  normal                        |   Milestone:  Future Release
Component:  Canonical                     |     Version:  3.0.1
 Severity:  normal                        |  Resolution:
 Keywords:  needs-unit-tests needs-patch  |
------------------------------------------+-----------------------------
Changes (by juliobox):

 * cc: juliobosk@… (added)


Comment:

 Waiting for a fix, i created this hack:


 {{{
 add_action( 'wp', 'baw_non_duplicate_content' );
 function baw_non_duplicate_content()
 {
         global $wp_query;
         if( isset( $wp_query->query_vars['category_name'],
 $wp_query->query['category_name'] )
                 && $wp_query->query_vars['category_name'] !=
 $wp_query->query['category_name'] ):

                 $correct_url = str_replace(
 $wp_query->query['category_name'], $wp_query->query_vars['category_name'],
 $wp->request );
                 wp_redirect( home_url( $correct_url ), 301 );
                 die();
         endif;
 }
 }}}

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/18734#comment:5>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list