• Hello guys, I’m using this to add a “handle” query parameter:

    add_rewrite_tag('%handle%', '([^&]+)');
    add_rewrite_rule('^product/([A-Za-z\-]+)/?', 'index.php?handle=$matches[1]', 'top');

    Which works. But sometimes, when handle is something like “myproduct-25”, the handle parameter value comes as “myproduct-“, without the “25”.

    This is how I fetch the value:

    global $wp_query;
    echo $wp_query->query_vars['handle']

    Does anyone know why this happens and how to fix?

    Thanks a bunch!

Viewing 1 replies (of 1 total)
  • Thread Starter pedronetto_brisa

    (@pedronetto_brisa)

    40 minutes later, problem solved:

    My rewrite rule wasn’t prepared to parse numbers, that’s all. The right rule would be:

    add_rewrite_rule('^product/([A-Za-z0-9\-]+)/?', 'index.php?handle=$matches[1]', 'top');

    Case closed.

Viewing 1 replies (of 1 total)
  • The topic ‘query_vars value mysteriously modified on the way’ is closed to new replies.