I have custom type post named 'team' as follows:
add_action( 'init', 'my_team_members' );
function my_team_members() {
register_post_type( 'team', array(
'labels' => array(
'name' => 'Team Members',
'singular_name' => 'Team Member',
),
'description' => 'The Team Members',
'public' => true,
'menu_position' => 20,
'supports' => array( 'title','custom-fields' ),
'rewrite' => array('slug' => 'our-team'),
));
}
So if I add a new team member named 'John' (and set the slug as 'john'), this url: http://www.domain.com/our-team/john will show the team member's profile.
I've added a new 'meta' named "firm". So a team member can be belong to firmA or to firmB. If the member is from firmA - the url above should show their profile.
The problem is that I want that: If the member is from firmB - this url: domain.com/firmB/our-team/john should show their profile.
Before doing any further changes , if I go to /firmB/our-team/john
wordpress will automatically redirect me to /our-team/john.
I've tried add_rewrite_rule without success.
function firmB_team_rewrite(){
add_rewrite_rule("[firmB/our-team/(.+?)/?$]","index.php?post_type=team&team=$matches[1]","top");
}
add_action( 'init', 'firmB_team_rewrite' );
I believe it's possible so my guess is that I'm missing something over here.