I need to pass query string


to look like this:


and it should work on any page:


I am looking for the simplest way to do this on wordpress. It would be awesome if it could be achieved on htaccess, because I am not really into wordpress functions and it's very hard for me to deal with it.

What I already tried are some functions from this question: How can I Rewrite a 'page' URL based on query string parameters?

One that I thought will be successful from the same question was this:

add_rewrite_rule('^(onepage)/([^/]*)/([^/]*)/?', 'index.php?name=$matches[1]&query=$matches[2]','top');

add_filter('query_vars', 'foo_my_query_vars');
function foo_my_query_vars($vars){
    $vars[] = 'query';
    return $vars;

I have added it to my theme functions and have tried checking that "/onepage" to get code firstly working only on it (because I am not sure how to make it work on all of the pages).

So however I wasn't able to get it working.

I can't find a way to the answer, but I believe, there is really simple solution for this. Maybe someone of you know it? Or maybe you could give some tip to find the solution?

  • The linked question already has a complete answer. What exactly has you tried without success? Please, post the code you have tried or we can end up repeating the same already said in the linked quesiton. – cybmeta Feb 21 '16 at 10:45
  • @cybmeta I have updated my question with one of the codes from that another question, that I tried. I added this code only because I think it should be successful as it is marked as right answer on another question. However it doesn't work for me. – Simon Feb 21 '16 at 11:02
  • what happens when you want to have a child page? how will you distinguish between a child page and your querystring value? – Milo Feb 21 '16 at 16:25

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.