WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using WP 3.2.1.

I try to do permalink like: /en/1/some-string. Structure is: %lang%/%pageID%/%some random string%

So I add a rewrite rule:

function  nw_lang_addRewrite($aRules) {
    $_aRules["(en|lt|ru)/(\d+)(/.*)?$"] = 'index.php?p=$matches[2]&lang=$matches[1]';

    $aRules = $_aRules + $aRules;
    return $aRules;

add a lang tag:

function nw_lang_addQuery($vars) {
    $aVars[] = "lang";
    return $aVars;

Buf if user go to http://www.somesite.com/en/17/2-Pork.html he dont see page with ID = 17.

$wp_query is:

WP_Query Object (
    [query_vars] => Array
            [lang] => en
            [error] => 
            [m] => 0
            [p] => 0


            [static] => 
            [pagename] => 
            [page_id] => 0
            [paged] => 0


    [is_single] => 
    [is_preview] => 
    [is_page] => 
    [is_paged] => 


    [queried_object] => 
    [queried_object_id] => 0
share|improve this question
up vote 0 down vote accepted

I found a problem. I needed change function parameter name to "$aVars".

function nw_lang_addQuery($avars)
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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