Use the same permalink structure for multiple taxonomies

37 views Asked by At

I have a WP site where there are 3 taxonomies, the main categories, companies and regions. I'm looking for them to all use the same permalink structure like:

site.com/{category-slug} site.com/{company-slug} site.com/{region-slug}

Is there a way to make this work and rewrite the urls within functions.php? I've tried a couple of methods, but sometimes they work, but then the main pages 404.

Thanks in advance

1

There are 1 answers

0
Rajesh Raval On

Have you tried this?

    function change_custom_taxonomy() {
    $custom_category_args = get_taxonomy( 'custom_category_slug' );
    $custom_category_args->show_admin_column = true;
    $custom_category_args->rewrite['slug'] = 'category_slug_which_you_want';
    $custom_category_args->rewrite['with_front'] = false;
    register_taxonomy( 'custom_category_slug', 'category_slug_which_you_want', (array) $custom_category_args );
}
add_action( 'init', 'change_custom_taxonomy', 11 );