A basic implementation could go like this:
Setup public query variables
This lets you fetch these later through get_query_var()
add_filter( 'query_vars', function( $vars ) {
$vars[] = 'team_category';
$vars[] = 'team_id';
return $vars;
} );
Add a rewrite rule
This is responsible for turning a url like /team/allstars/999
into a format WordPress can handle. Make sure to replace your_page_id
with the actual ID of your teams page.
add_action( 'init', function() {
add_rewrite_rule( '^teams/([^/]*)/([^/]*)/?', 'index.php?page_id=your_page_id&team_category=$matches[1]&team_id=$matches[2]', 'top' );
} );
Add your shortcode
Just an example of grabbing and outputting your query variables.
add_shortcode( 'teams', function() {
$team_category = get_query_var( 'team_category' );
$team_id = get_query_var( 'team_id' );
return "{$team_category}: {$team_id}";
} );
Heads up: when tinkering with rewrite rules, make sure to trigger a permalink refresh by clicking Save Changes in your Settings → Permalinks screen (without making any changes, even).