query_vars and permalinks question
-
Hi,
I have a question regarding setting up my own get vars in WP and grabing them while using the pretty permalink structure.
I know that there have been some topics about it and even tutorials on the web. But I still cant manage to get it to work so I wanted to ask for help with my example.
So what I did.
First:
regster the new variable ‘nng_users’:function nng_users_query_vars( $vars ) { array( $vars, 'nng_users' ); return $vars; } add_filter('query_vars', 'nng_users_query_vars');
Second:
adding rewrite rules:function nng_users_rewrite_rules( $rules ) { $newrules = array( "benutzer/([^/]+)/?$" => "index.php?pagename=user&nng_users=$matches[1]" ); $finalrules = $newrules + $rules; return $finalrules; } add_filter('rewrite_rules_array','nng_users_rewrite_rules');
So for my understanding: WordPress _should_ recognize the nng_users variable which is submitted whenever an url goes like https://www.xyz.de/benutzer/whatev/
And in this particular case, it should call the page with the slug “user”.But it just doesn’t seem to register the damn nng_users variable. When I type e.g. /benutzer/register/ it calls the user page, which is correct. But I the $wp_query->query_vars array does not hold the nng_users variable… Am I missing something?
- The topic ‘query_vars and permalinks question’ is closed to new replies.