Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I need to rewrite some urls:

I have a page (id = 61), with slug anunciantes on wich I use a custom template to generate a wp_query to list a custom post_type.

I need to be able to filter by two different taxonomies, area and category

function rewrite_rules() { 
    /* Tried:
        global $wp_rewrite;
        $wp_rewrite->flush_rules();
    */
    add_rewrite_rule('^/?anunciantes/(.*)/(.*)/$',
                '/anunciantes/?area=$matches[1]&category=$matches[2]',
                'top'); 
   /* Also tried:
   add_rewrite_rule('^/?anunciantes/(.*)/(.*)/$',
                'index.php?page_id=61&area=$matches[1]&category=$matches[2]',
                'top'); 
   */
}
add_action('init', 'rewrite_rules');

But I allways get 404 error if I try:

/anunciantes/one/two/

( I did go to wp-admin -> permalinks -> save changes , I understand it flushes the rewrite rules? )

So, any idea what am I doing wrong?

share|improve this question
    
Try a plugin for rewrite rules debug, for example Monkeyman Rewrite Analyzer, and see what's going on. –  Rarst Jun 9 at 21:55
    
Did you register your custom query string vars? Read the Important bit in the codex –  vancoder Jun 9 at 22:03

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.