custom post type and custom taxonomy permalink

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.

Leave a Comment