Quick simple question. How would I get the result of a rewrite in wordpress?

For example I have:

www.some.website.com/some/parameter

How would I get the end result that WP processes? Aka, the

www.some.website.com/index.php?paramter1=some&paramter2=parameter

Cheers

2 Answers
2

Have a look at the Action Reference to see generally how requests are processed. After all the loading and init stuff happens, the parse_request action runs when the request is matched against the rewrite rules, and an object is passed containing all the registered query vars and the matched rule and query string.

function wpd_parse_request( $request ){
    echo $request->matched_query;
}
add_action( 'parse_request', 'wpd_parse_request' );

After the wp action runs, that same object is stashed in the wp global.

global $wp;
echo $wp->matched_query;

Leave a Reply

Your email address will not be published. Required fields are marked *