i explain what i try to do. First i have WP 5.2 and Php 7.2.

i have a form which send a variable array like myVar[] to another page template. the url is http://mysite/mypage.html?myVar[]=item1&myVar[]=item2 I would like an url like : http://mysite/mypage/item1/item2

I have this on functions.php :

 add_action('init', 'add_my_rewrite2');

function add_my_rewrite2() {
  global $wp_rewrite;


and i have this in the template of the receiving page :

 Template Name: x-page


global $wp_query;
$myVar1 = $wp_query->query_vars['myVar'][0];
$myVar2 = $wp_query->query_vars['myVAr'][1];
echo 'myVar1 : ' . $myVar1;
echo 'myVar2 : ' . $myVar2;


I receive the value and the echo are correct but the url is not rewrited.

I've tried many stuff like put the [] too the variable or the [0] and [1] and others stuff but nothing works.

if anyone can help me please. thanks.

Your Answer

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

Browse other questions tagged or ask your own question.