WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I link to another WordPress page but move variables to it as well (preferably not through the address bar)?
For instance, I have on one page a list of shops in which a user should be able to click on a shop, which would then open the shop page with the correct data.
So the shop's id needs to move from the shops list page to the shop page.

share|improve this question
up vote 1 down vote accepted

you could POST the shop id to the target page. otherwise- cookie, session. or just fetch it on the list page via ajax.

edit - a simple post request via a form:

in your source page:

<form action="b.php" method="post">
    <input type="hidden" name="id" value="42" />
    <input type="submit" />

in the target page b.php:

if( isset($_POST['id']) ):
    echo $_POST['id'];
share|improve this answer
Can you elaborate on the latter? I need to pass the shop ID from the list page to the shop page. How would I do it with ajax? – Ash Aug 4 '11 at 20:48
Not via ajax, I was suggesting not taking the viewer to another page and just fetching the contents of the shop page for the selected shop via ajax and displaying it on the list of shops page. – Milo Aug 4 '11 at 21:00
I see. So if I do want to open the shop on a different page my only two options are posting variables through the address bar and using cookies? – Ash Aug 4 '11 at 21:14
passing variables via the address bar is a GET request, ie: page?myvar=foo. a POST request passes the variable in a way that's hidden to the viewer and shows the plain URL. or a cookie. – Milo Aug 4 '11 at 21:35
Can you please give an example for using the post method? – Ash Aug 4 '11 at 21:49

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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