You can use a rewrite endpoint for this.
The first step is to give your custom taxonomy an endpoint mask when you register the taxonomy:
$args = [
'rewrite' => [
'slug' => 'topic',
'ep_mask' => EP_CATEGORIES
],
// the rest of your args...
];
register_taxonomy( 'topic', array( 'post' ), $args );
The next step is to add the endpoint. This should be hooked to run on init
, just like your taxonomy registration code.
add_rewrite_endpoint( 'type', EP_CATEGORIES );
Don’t forget to flush rewrite rules after adding this code. The easiest way to do this is by visiting the Settings > Permalinks page.
You should now be able to add type/newsletter
onto the end of your taxonomy links. To access the passed value, use get_query_var
:
$type = get_query_var( 'type', false );
If the code currently expects to find type
in $_GET['type']
and you can’t change that, you can manually set that value before the code that tries to access it:
$_GET['type'] = get_query_var( 'type', false );