I want to pass a parameter to a page from the one visited before and use it in a shortcode function. For this, I am writing in the scope of a function in functions.php :


But it always return empty. What is the correct way to do this ?


My guess is that functions.php has an empty $_POST when called as it is called by an other file, not directly by the user. How can I access the _POST data in functions.php then ?

  • And how are you passing this value? $_POST is availabe with POST requests only. If you don't use POST request from one page to another, $_POST will be empty. – Milan Petrovic Sep 17 '17 at 21:14

Try adding you query variable to the public query variable list like this.

function wp280272_query_vars($vars) {
  $vars[] = 'currency';
  return $vars;
add_filter( 'query_vars', 'wp280272_query_vars' );

you then can access it via

  • Thanks for the answer ! In what file should I writte this bit of code ? In functions.php ? – An intern has no name Sep 17 '17 at 20:16
  • Ok, I used this in functions.php and it worked, thanks ! – An intern has no name Sep 18 '17 at 0:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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