You could add a rewrite rule. Rewrite rules are the regular expressions that WP uses to parse out the query from friendly URLs. But I think this would potentially mess things up. How would WP distinguish between
A better option, I think, would be to hook into the
parse_request action. This gets called after WP loads what it thinks are the query vars, but before it makes the query (and so before it decides that the request should be "not found.") This action hook passes the WP object to your function by reference.
* @param WP $wp
For an existing page
server.loc/sample-page/ this outputs:
$wp is passed by reference you can change
$wp->query_vars directly, after checking what parts of
page_name are actually pages and storing your parameters for use later.
$wp->query_vars refers to the page number, if any. All you should touch is
The code from which
parse_request is called is in