First, add a WordPress page named game
to direct requests to.
Next, add the game
query var so WordPress knows what it is:
add_filter( 'query_vars', 'wpa_query_vars' );
function wpa_query_vars( $query_vars ){
$query_vars[] = 'game';
return $query_vars;
}
Then, add a rewrite rule to handle the incoming requests and direct them to your page:
add_action( 'init', 'wpa_add_game_rule' );
function wpa_add_game_rule() {
add_rewrite_rule(
'game/([^/]+)/?',
'index.php?pagename=game&game=$matches[1]',
'top'
);
}
Last, create a template named page-game.php
and add get_query_var( 'game' )
to see the requested game.