I have 2 pages.


I have a custom post type, called "case":

$case_type = array(
    'labels' => $case_labels,
    'public' => true,
    'publicly_queryable' => true,
    'show_ui' => true,
    'query_var' => 'case',
    'rewrite' => array( 'slug' => 'cases', 'with_front' => false ),
    'capability_type' => 'post',
    'hierarchical' => false,
    'menu_position' => 46,
    'has_archive' => true,
    'supports' => array('title','editor'),
register_post_type( 'case' , $case_type );

And finally I have a custom taxonomy, called "type":

    'public' => TRUE,
    'show_tagcloud' => FALSE,
    'hierarchical' => TRUE,
    'labels' => $categoria_labels,
    'show_ui' => TRUE,
    'query_var' => TRUE,
    'rewrite' => array( 'slug' => 'genre', 'with_front' => false )

All my types has the same name of my pages: client-a, client-b.

How can I rewrite the permalink rules to accept this structure:

client-a/ --> page, lists all 'cases', uses a template
client-a/subpage --> this is a subpage

client-a/cases/case-a.html --> this is a custom post type WITH the genre "client-a"
client-b/cases/case-b.html --> this is a custom post type WITH the genre "client-b"

What is the best approach for this structure?

Whem I'm using this solution: http://xplus3.net/2010/05/20/wp3-custom-post-type-permalinks/comment-page-1/#comment-1005

I get my permalinks working for custom post types and custom taxonomy, but breaks all my pages permalinks.


  • 1
    just a note: I believe that the name 'type' for a custom taxonomy is a Reserved Term and can cause problems codex.wordpress.org/Function_Reference/…
    – Bainternet
    Commented Jun 15, 2011 at 21:26
  • hi there.. this is just a sample, on my code, the real name of the taxonomy is "genre". Commented Jun 16, 2011 at 13:58
  • Hi @HomemRobô, is this still an open question? I'd be happy to help you sort this out if it is. If not, it would be great if you could post your solution for others! Commented Jan 30, 2012 at 1:28

1 Answer 1


Something similar to this in your functions.php or a plugin will do the trick:

function custom_rewrite( $wp_rewrite ) {
    $feed_rules = array(
        '([^/]+)/cases/([^/]+).html'    =>  'index.php?genre='. $wp_rewrite->preg_index(1) .'&case='. $wp_rewrite->preg_index(2)
    $wp_rewrite->rules = $feed_rules + $wp_rewrite->rules;
// refresh/flush permalinks in the dashboard if this is changed in any way
add_filter( 'generate_rewrite_rules', 'custom_rewrite' );

You will need to refresh/flush your permalinks (WP Dashboard > Settings > Permalinks > Save Changes) when you add/edit/remove that code. You may need to adjust it slightly if it doesn't work as is, but it demonstrates the basic principle of how to do it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.