I’m writing a WordPress page with a form on it (imagine http://example.com/form) that will redirect to another WordPress page (http://example.com/confirmation). I want to pass some information from the form to the confirmation page. (I don’t want to write a separate confirmation page for each product.)

I figure that a query string on the URI, like http://example.com/confirmation?product=A is a logical way to pass a value from the form to the confirmation. On the confirmation page, I want to use this value:

Thank you for your interest in '{product}'.

Except I don’t know how to interpolate the value of product from the URI into the document.

I do use the Code Snippet plugin for WordPress, so I can create a shortcode that I could call from within the confirmation page, like this:

Thank you for your interest in '[my_shortcode product="{product}"]'.

This just kicks the can down the road, because I don’t know what to use in place of {product} here, either.

Alternatively, it would be just as well if the function behind the shortcode (which I’ll write myself) could access the product query string from the URI, in which case, I could just say:

Thank you for your interest in '[my_shortcode]'.

…With the shortcode defined like this:

add_shortcode("my_shortcode", "f");
function f($atts) {
  return "{product}";  // from the product query string in the URI
}

But, alas, I don’t know what to write in place of {product} here, either.

Is there a solution for any of the three of these problems, that would spare me from writing a separate confirmation page for each product?

Read more here: How to use a URI query string value within a WordPress page?


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: