[wp-hackers] Rewrite rules for combined category and custom taxonomies

Mark Jaquith markjaquith at gmail.com
Sun May 16 18:02:34 UTC 2010


On Sun, May 16, 2010 at 1:49 PM, wjm <776a6d at gmail.com> wrote:
> Instead of staying in: */especialidad/enfermeria/especialidad-cursos/*
> I keep getting redirected to: */info/especialidad/enfermeria/*
> (*info* is the *category base*).

It is likely the canonical redirect functionality that is doing that.
Your rewrite rule makes WordPress think it is a category query. You
can hook in to the 'redirect_canonical' filter to conditionally
disable this redirect.

Here is how it is called.

> $redirect_url = apply_filters('redirect_canonical', $redirect_url, $requested_url);

If you pass back FALSE, it will cancel the redirect.

If you hook in before template_redirect is fired, you could also
conditionally disable the canonical redirect code. Might be more
efficient.

This is how it is called:

> add_action('template_redirect', 'redirect_canonical');

Some test like this could be used to trigger the override:
get_query_var( 'taxonomy' ) == 'especialidad_informacion' &&
get_query_var( 'category_name' )

-- 
Mark Jaquith


More information about the wp-hackers mailing list