Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a problem writing a plugin for wordpress. First, I register a new query_var and add a new rewrite rule:

function nng_users_query_vars( $vars ) {
    array_push( $vars, 'nng_users' );
    return $vars;
}
add_filter('query_vars', 'nng_users_query_vars');

function nng_users_rewrite_rules( $rules ) {
$newrules = array(
                        'benutzer/([^/]+)/?$' => 'index.php?pagename=nng_users&nng_users=$matches[1]'
                      );
$finalrules = $newrules + $rules;
    return $finalrules;
}
add_filter('rewrite_rules_array','nng_users_rewrite_rules');

This works perfectly, but I cannot grab any query_var from the plugin. Typing:

print_r( $wp_query->query_var );

or

echo $wp_query->query_var['some_var'];

does not show anything. But why? If I put the exact same thing into the function of my theme, it works. If I put it into a function and call this function in my theme, it works... Background is the following: I want to create a custom user system and therefore I need to check my custom query var to e.g. logout or header-redirect.

Thanks in advance

share|improve this question
    
and of course I tried to global $wp_query –  clash Jul 29 '12 at 11:54
    
is $wp_query->query_var a typo? it's plural: $wp_query->query_vars –  Milo Jul 29 '12 at 13:47
    
its a typo, sry about that. I used $wp_query->query_vars of course –  clash Jul 29 '12 at 15:21

1 Answer 1

Late answer, but for everybody else looking for it, this works:

http://codex.wordpress.org/Function_Reference/get_query_var

share|improve this answer

Your Answer

 
discard

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.