Combining Multiple Taxonomies in one URL

This rewrite rule should work (assuming “brand” and “type” are the taxonomy registered names):

function custom_rewrite_rules() {
    add_rewrite_rule('^brand/(.*)/type/(.*)?', 'index.php?brand=$matches[1]&type=$matches[2]', 'top');
}
add_action('init', 'custom_rewrite_rules');

Remember to flush the rewirte rules after saving this code in your site.

Then you will need to hook in several places to fix things. For example, you may need to hook wp_title to generate the correct title for the document, for example “HP Printers” instead or just “HP”, as this won’t be handle automatically by WordPress. I can’t give a exhaustive list of things you will need to fix.

Leave a Comment