I have a custom taxonomy called activities and a custom role called operator. So, if example.com/operators/bird-watching is visited then I want to list all the operators that offers bird-watching. Bird-watching is a term of activities taxonomy. I have made a different template for this. I have also developed a url structure for this which is show below. All I want now is to load my custom template if someone visits example.com/operators/bird-watching
Tried this link but no help.
function resources_cpt_generating_rule($wp_rewrite) {
global $wp_rewrite;
$rules = array();
$terms = get_terms( array(
'taxonomy' => 'activities',
'hide_empty' => false,
) );
$post_type = 'operator';
foreach ($terms as $term) {
$rules['operators/' . $term->slug . '/([^/]*)$'] = 'index.php?operators/'.$term->slug;
}
// merge with global rules
$wp_rewrite->rules = $rules + $wp_rewrite->rules;
}
add_action( 'generate_rewrite_rules', 'resources_cpt_generating_rule' );