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

wjm 776a6d at gmail.com
Sun May 16 17:49:24 UTC 2010


Hi everyone,
*this is my very first message in this list.*

I am having trouble defining a rewrite rule that *combines categories and
custom taxonomies.*
The latter is being overwritten by a following category rewrite rule.

*Is there a way to say, if the first rule matched, forget about the rest of
the rules?*
*
*
*This is the situation:*
I want to display all the posts in a subcategory, that have a certain custom
taxonomy.
But it seems impossible almost impossible.

URL Path: */especialidad/enfermeria/especialidad-cursos/*
*
*
Where
"*/especialidad/enfermeria*" is the *category/subcategory*
and
"*especialidad-cursos*" is the *term *for the *custom taxonomy
"especialidad_informacion" *

I created a rule that catches this
the rewrite rule is as follow:
*$rr_rewrite_rules = array(
  '(especialidad/[^/]+)/([^/]+)/?$' =>
'index.php?category_name=$matches[1]&taxonomy=especialidad_informacion&term=$matches[2]',
);*

Rules are added to the top of the rewrite rules.

Instead of staying in: */especialidad/enfermeria/especialidad-cursos/*
I keep getting redirected to: */info/especialidad/enfermeria/*
(*info* is the *category base*).
In one of the many tries, I got redirected to */info/especialidad/enfermeria
/?**especialidad_informacion=**especialidad-cursos*
*but i cannot reproduce that anymore.*
*
*
the custom taxonomy was created with the following code
*add_action( 'init', 'build_taxonomies', 0 );
function build_taxonomies() {
  register_taxonomy( 'especialidad_informacion', 'post', array(
'hierarchical' => true, 'label' => 'Información de Especialidades',
'query_var' => true, 'rewrite' => true, ) );
}

*
*attached is the rewrite rule plugin and the print of the wp_rewrite object
to see what may be causing trouble.*

thanks a whole lot for reading.

- wjm
-------------- next part --------------
WP_Rewrite Object
(
    [permalink_structure] => /%year%/%monthnum%/%postname%/
    [use_trailing_slashes] => 1
    [category_base] => info
    [tag_base] => temas
    [tag_structure] => /temas/%tag%
    [author_base] => author
    [search_base] => search
    [comments_base] => comments
    [feed_base] => feed
    [comments_feed_structure] => 
    [front] => /
    [root] => 
    [index] => index.php
    [matches] => matches
    [rules] => Array
        (
            [(especialidad/[^/]+)/([^/]+)/?$] => index.php?category_name=$matches[1]&taxonomy=especialidad_informacion&term=$matches[2]
            [especialidad_informacion/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?especialidad_informacion=$matches[1]&feed=$matches[2]
            [especialidad_informacion/([^/]+)/(feed|rdf|rss|rss2|atom)/?$] => index.php?especialidad_informacion=$matches[1]&feed=$matches[2]
            [especialidad_informacion/([^/]+)/page/?([0-9]{1,})/?$] => index.php?especialidad_informacion=$matches[1]&paged=$matches[2]
            [especialidad_informacion/([^/]+)/?$] => index.php?especialidad_informacion=$matches[1]
            [robots\.txt$] => index.php?robots=1
            [.*wp-atom.php$] => index.php?feed=atom
            [.*wp-rdf.php$] => index.php?feed=rdf
            [.*wp-rss.php$] => index.php?feed=rss
            [.*wp-rss2.php$] => index.php?feed=rss2
            [.*wp-feed.php$] => index.php?feed=feed
            [.*wp-commentsrss2.php$] => index.php?feed=rss2&withcomments=1
            [feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?&feed=$matches[1]
            [(feed|rdf|rss|rss2|atom)/?$] => index.php?&feed=$matches[1]
            [page/?([0-9]{1,})/?$] => index.php?&paged=$matches[1]
            [comment-page-([0-9]{1,})/?$] => index.php?&page_id=177&cpage=$matches[1]
            [comments/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?&feed=$matches[1]&withcomments=1
            [comments/(feed|rdf|rss|rss2|atom)/?$] => index.php?&feed=$matches[1]&withcomments=1
            [comments/page/?([0-9]{1,})/?$] => index.php?&paged=$matches[1]
            [search/(.+)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?s=$matches[1]&feed=$matches[2]
            [search/(.+)/(feed|rdf|rss|rss2|atom)/?$] => index.php?s=$matches[1]&feed=$matches[2]
            [search/(.+)/page/?([0-9]{1,})/?$] => index.php?s=$matches[1]&paged=$matches[2]
            [search/(.+)/?$] => index.php?s=$matches[1]
            [info/(.+?)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?category_name=$matches[1]&feed=$matches[2]
            [info/(.+?)/(feed|rdf|rss|rss2|atom)/?$] => index.php?category_name=$matches[1]&feed=$matches[2]
            [info/(.+?)/page/?([0-9]{1,})/?$] => index.php?category_name=$matches[1]&paged=$matches[2]
            [info/(.+?)/?$] => index.php?category_name=$matches[1]
            [temas/(.+?)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?tag=$matches[1]&feed=$matches[2]
            [temas/(.+?)/(feed|rdf|rss|rss2|atom)/?$] => index.php?tag=$matches[1]&feed=$matches[2]
            [temas/(.+?)/page/?([0-9]{1,})/?$] => index.php?tag=$matches[1]&paged=$matches[2]
            [temas/(.+?)/?$] => index.php?tag=$matches[1]
            [author/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?author_name=$matches[1]&feed=$matches[2]
            [author/([^/]+)/(feed|rdf|rss|rss2|atom)/?$] => index.php?author_name=$matches[1]&feed=$matches[2]
            [author/([^/]+)/page/?([0-9]{1,})/?$] => index.php?author_name=$matches[1]&paged=$matches[2]
            [author/([^/]+)/?$] => index.php?author_name=$matches[1]
            [([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&feed=$matches[4]
            [([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/(feed|rdf|rss|rss2|atom)/?$] => index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&feed=$matches[4]
            [([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/page/?([0-9]{1,})/?$] => index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&paged=$matches[4]
            [([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/?$] => index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]
            [([0-9]{4})/([0-9]{1,2})/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?year=$matches[1]&monthnum=$matches[2]&feed=$matches[3]
            [([0-9]{4})/([0-9]{1,2})/(feed|rdf|rss|rss2|atom)/?$] => index.php?year=$matches[1]&monthnum=$matches[2]&feed=$matches[3]
            [([0-9]{4})/([0-9]{1,2})/page/?([0-9]{1,})/?$] => index.php?year=$matches[1]&monthnum=$matches[2]&paged=$matches[3]
            [([0-9]{4})/([0-9]{1,2})/?$] => index.php?year=$matches[1]&monthnum=$matches[2]
            [([0-9]{4})/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?year=$matches[1]&feed=$matches[2]
            [([0-9]{4})/(feed|rdf|rss|rss2|atom)/?$] => index.php?year=$matches[1]&feed=$matches[2]
            [([0-9]{4})/page/?([0-9]{1,})/?$] => index.php?year=$matches[1]&paged=$matches[2]
            [([0-9]{4})/?$] => index.php?year=$matches[1]
            [[0-9]{4}/[0-9]{1,2}/[^/]+/attachment/([^/]+)/?$] => index.php?attachment=$matches[1]
            [[0-9]{4}/[0-9]{1,2}/[^/]+/attachment/([^/]+)/trackback/?$] => index.php?attachment=$matches[1]&tb=1
            [[0-9]{4}/[0-9]{1,2}/[^/]+/attachment/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?attachment=$matches[1]&feed=$matches[2]
            [[0-9]{4}/[0-9]{1,2}/[^/]+/attachment/([^/]+)/(feed|rdf|rss|rss2|atom)/?$] => index.php?attachment=$matches[1]&feed=$matches[2]
            [[0-9]{4}/[0-9]{1,2}/[^/]+/attachment/([^/]+)/comment-page-([0-9]{1,})/?$] => index.php?attachment=$matches[1]&cpage=$matches[2]
            [([0-9]{4})/([0-9]{1,2})/([^/]+)/trackback/?$] => index.php?year=$matches[1]&monthnum=$matches[2]&name=$matches[3]&tb=1
            [([0-9]{4})/([0-9]{1,2})/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?year=$matches[1]&monthnum=$matches[2]&name=$matches[3]&feed=$matches[4]
            [([0-9]{4})/([0-9]{1,2})/([^/]+)/(feed|rdf|rss|rss2|atom)/?$] => index.php?year=$matches[1]&monthnum=$matches[2]&name=$matches[3]&feed=$matches[4]
            [([0-9]{4})/([0-9]{1,2})/([^/]+)/page/?([0-9]{1,})/?$] => index.php?year=$matches[1]&monthnum=$matches[2]&name=$matches[3]&paged=$matches[4]
            [([0-9]{4})/([0-9]{1,2})/([^/]+)/comment-page-([0-9]{1,})/?$] => index.php?year=$matches[1]&monthnum=$matches[2]&name=$matches[3]&cpage=$matches[4]
            [([0-9]{4})/([0-9]{1,2})/([^/]+)(/[0-9]+)?/?$] => index.php?year=$matches[1]&monthnum=$matches[2]&name=$matches[3]&page=$matches[4]
            [[0-9]{4}/[0-9]{1,2}/[^/]+/([^/]+)/?$] => index.php?attachment=$matches[1]
            [[0-9]{4}/[0-9]{1,2}/[^/]+/([^/]+)/trackback/?$] => index.php?attachment=$matches[1]&tb=1
            [[0-9]{4}/[0-9]{1,2}/[^/]+/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?attachment=$matches[1]&feed=$matches[2]
            [[0-9]{4}/[0-9]{1,2}/[^/]+/([^/]+)/(feed|rdf|rss|rss2|atom)/?$] => index.php?attachment=$matches[1]&feed=$matches[2]
            [[0-9]{4}/[0-9]{1,2}/[^/]+/([^/]+)/comment-page-([0-9]{1,})/?$] => index.php?attachment=$matches[1]&cpage=$matches[2]
            [([0-9]{4})/([0-9]{1,2})/comment-page-([0-9]{1,})/?$] => index.php?year=$matches[1]&monthnum=$matches[2]&cpage=$matches[3]
            [([0-9]{4})/comment-page-([0-9]{1,})/?$] => index.php?year=$matches[1]&cpage=$matches[2]
            [.+?/attachment/([^/]+)/?$] => index.php?attachment=$matches[1]
            [.+?/attachment/([^/]+)/trackback/?$] => index.php?attachment=$matches[1]&tb=1
            [.+?/attachment/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?attachment=$matches[1]&feed=$matches[2]
            [.+?/attachment/([^/]+)/(feed|rdf|rss|rss2|atom)/?$] => index.php?attachment=$matches[1]&feed=$matches[2]
            [.+?/attachment/([^/]+)/comment-page-([0-9]{1,})/?$] => index.php?attachment=$matches[1]&cpage=$matches[2]
            [(.+?)/trackback/?$] => index.php?pagename=$matches[1]&tb=1
            [(.+?)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?pagename=$matches[1]&feed=$matches[2]
            [(.+?)/(feed|rdf|rss|rss2|atom)/?$] => index.php?pagename=$matches[1]&feed=$matches[2]
            [(.+?)/page/?([0-9]{1,})/?$] => index.php?pagename=$matches[1]&paged=$matches[2]
            [(.+?)/comment-page-([0-9]{1,})/?$] => index.php?pagename=$matches[1]&cpage=$matches[2]
            [(.+?)(/[0-9]+)?/?$] => index.php?pagename=$matches[1]&page=$matches[2]
        )
 
    [extra_rules] => Array
        (
        )
 
    [extra_rules_top] => Array
        (
            [especialidad_informacion/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?especialidad_informacion=$matches[1]&feed=$matches[2]
            [especialidad_informacion/([^/]+)/(feed|rdf|rss|rss2|atom)/?$] => index.php?especialidad_informacion=$matches[1]&feed=$matches[2]
            [especialidad_informacion/([^/]+)/page/?([0-9]{1,})/?$] => index.php?especialidad_informacion=$matches[1]&paged=$matches[2]
            [especialidad_informacion/([^/]+)/?$] => index.php?especialidad_informacion=$matches[1]
        )
 
    [non_wp_rules] => Array
        (
        )
 
    [extra_permastructs] => Array
        (
            [especialidad_informacion] => Array
                (
                    [0] => /especialidad_informacion/%especialidad_informacion%
                    [1] => 0
                )
 
        )
 
    [endpoints] => Array
        (
        )
 
    [use_verbose_rules] => 
    [use_verbose_page_rules] => 
    [rewritecode] => Array
        (
            [0] => %year%
            [1] => %monthnum%
            [2] => %day%
            [3] => %hour%
            [4] => %minute%
            [5] => %second%
            [6] => %postname%
            [7] => %post_id%
            [8] => %category%
            [9] => %tag%
            [10] => %author%
            [11] => %pagename%
            [12] => %search%
            [13] => %especialidad_informacion%
        )
 
    [rewritereplace] => Array
        (
            [0] => ([0-9]{4})
            [1] => ([0-9]{1,2})
            [2] => ([0-9]{1,2})
            [3] => ([0-9]{1,2})
            [4] => ([0-9]{1,2})
            [5] => ([0-9]{1,2})
            [6] => ([^/]+)
            [7] => ([0-9]+)
            [8] => (.+?)
            [9] => (.+?)
            [10] => ([^/]+)
            [11] => (.+?)
            [12] => (.+)
            [13] => ([^/]+)
        )
 
    [queryreplace] => Array
        (
            [0] => year=
            [1] => monthnum=
            [2] => day=
            [3] => hour=
            [4] => minute=
            [5] => second=
            [6] => name=
            [7] => p=
            [8] => category_name=
            [9] => tag=
            [10] => author_name=
            [11] => pagename=
            [12] => s=
            [13] => especialidad_informacion=
        )
 
    [feeds] => Array
        (
            [0] => feed
            [1] => rdf
            [2] => rss
            [3] => rss2
            [4] => atom
        )
 
    [date_structure] => /%year%/%monthnum%/%day%
    [search_structure] => search/%search%
    [category_structure] => /info/%category%
    [author_structure] => /author/%author%
    [page_structure] => %pagename%
)


More information about the wp-hackers mailing list