[wp-trac] [WordPress Trac] #16627: Rewrite query vars are stripped from custom taxonomy page URLs via redirect_canonical()
WordPress Trac
wp-trac at lists.automattic.com
Thu Mar 10 22:17:25 UTC 2011
#16627: Rewrite query vars are stripped from custom taxonomy page URLs via
redirect_canonical()
---------------------------+--------------------
Reporter: gnoodl | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: 3.1.1
Component: Rewrite Rules | Version: 3.1
Severity: normal | Resolution:
Keywords: |
---------------------------+--------------------
Comment (by gnoodl):
Mine looks very similar to emartin's except I'm using rewrite rules.
Taxonomy code
{{{
register_taxonomy('my_taxonomy', 'custom_post_type', array(
'label' => __('My Taxonomy Name'),
'public' => true,
'rewrite' => array('slug' => 'my_slug_prefix'),
'query_var' => 'my_taxonomy_var'
));
}}}
Added query vars (using the {{{query_vars}}} filter)
{{{
$queryVars[] = 'criteria';
return $queryVars;
}}}
Rewrite Rules (using the {{{generate_rewrite_rules}}} action hook)
{{{
$rules = array(
'my_slug_prefix/(.+)/(.+)/(asc|desc)' => sprintf(
'index.php?taxonomy=my_taxonomy&my_taxonomy_var=%s&criteria=%s&order=%s',
$rewrite->preg_index(1), $rewrite->preg_index(2),
$rewrite->preg_index(3)),
'my_slug_prefix/(.+)/(.+)' => sprintf(
'index.php?taxonomy=my_taxonomy&my_taxonomy_var=%s&criteria=%s',
$rewrite->preg_index(1), $rewrite->preg_index(2))
);
$rewrite->rules = $rules + $rewrite->rules;
}}}
Like emartin's, mine worked fine in 3.0.5. Any matching URL is now
redirected to the default taxonomy page via canonical.php line 172
{{{
$redirect['path'] = $tax_url['path'];
}}}
--
Ticket URL: <http://core.trac.wordpress.org/ticket/16627#comment:6>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list