I need to receive some special $_GET parameters for a custom page I'm making, i know how to receive this through a simple $_GET like mysite.net/products/?id=1 , but I wanted to use the URL style of my WordPress like mysite.net/products/1.

How to retrieve $_GET variables from rewritten URLs?

  • I mistakenly close voted this as a duplicate... Commented Apr 10, 2012 at 12:07

1 Answer 1


To be added on init:

To register your custom variable ('id' in the question)


To create a re-write rule:


4 is the id of the 'product' page. You will need to flush rewrite rules once after adding these (go to Permalink settings page)

You can get the value of mycustomvar: get_query_var( 'mycustomvar' ).

See Codex for:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.