1

I have an issue similar to this one: Rewrite Rule for Custom Page with Query Vars in URL

We have those two rules we're trying to add through the Rewrite plugin. rewriting rules

We tested it and the GET parameters don't seem to follow as shown here. rewriting analysis

When using PHP on that resulting page to show the $_GET values, it's empty. The red bar on top of the parameters shows a tooltip saying "This query variable is not public and will not be saved".

Our page is available here: https://v2.magikweb.ca/commande

But we'd like to feed it dynamic with one or two parameters as such: https://v2.magikweb.ca/commande/web-hosting/plan-name

How do you make a custom GET parameter not public so this would work?

1 Answer 1

1

To fix this issue, we had to add the "query variables" into the functions.php of our theme to add them to the public variables.

function add_query_vars_filter($vars){
  $vars[] = "subject";
  $vars[] = "param";
  return $vars;
}
add_filter('query_vars', 'add_query_vars_filter');

This allowed us to retrieve the variables' value this way.

$subject = get_query_var('subject', false);

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.