[wp-trac] [WordPress Trac] #15256: ?cat=## permalinks do not redirect when category is a parent (was: wp_dropdown_categories() redirects parent categories to /?cat=##)

WordPress Trac wp-trac at lists.automattic.com
Wed Jun 22 05:02:28 UTC 2011


#15256: ?cat=## permalinks do not redirect when category is a parent
----------------------------------------+-----------------------------
 Reporter:  froman118                   |       Owner:
     Type:  defect (bug)                |      Status:  reopened
 Priority:  normal                      |   Milestone:  Future Release
Component:  Canonical                   |     Version:  3.0.1
 Severity:  normal                      |  Resolution:
 Keywords:  template redirect category  |
----------------------------------------+-----------------------------
Changes (by dd32):

 * keywords:  template redirect, category => template redirect category
 * component:  Permalinks => Canonical
 * milestone:   => Future Release


Comment:

 > As andrewspittle pointed out to me, cat=X doesn't redirect, there's no
 canonical there, only on category_name.

 Alright, So I've duplicated it. ?cat=123 redirects, as long as it's a
 child category or is a top level category with no children. ?cat=456
 doesn't redirect if it has childen, this is because the canonical code
 doesn't redirect on multiple category queries (which a parent category
 query is)

 A quick hack "hack" would be to restore a block like this before the
 current taxonomy redirection code:
 {{{
                 } elseif ( is_category() && !empty($_GET['cat']) ) {
                         if ( $redirect_url = get_term_link(
 (int)$_GET['cat'], 'category') )
                                 $redirect['query'] =
 remove_query_arg('cat', $redirect['query']);
 }}}
 however, that has the downside that it'll probably break on other taxonomy
 queries, or multi-query_var queries, which is what the current code was
 designed to fix.

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


More information about the wp-trac mailing list