Custom rewrite_rules – only pass numbers and not alphabetic characters

Instead of index.php/reco/?b=$1, try this: “$wp_rewrite->index?pagename=reco&b=” . $wp_rewrite->preg_index( 1 ) You should also append a $ to your reco/([^/]*)/? regex to ensure the rule only matches the entire path, and not just the beginning. Then flush your rules afterwards (just re-save your permalink settings in admin). Update: Try using the page_rewrite_rules filter instead, and use … Read more

get_query_var not works

Your filter: function add_query_vars_filter( $vars ){ $vars[] = “getvar”; return $vars; } add_filter( ‘query_vars’, ‘add_query_vars_filter’ ); Is correct. When WordPress starts assembling the list of query variables, this function will add ‘getvar’ to the list. But then you immediately check if the variable is set before it reaches that point. The query_vars filter hasn’t happened … Read more

query_vars filter not working even though query string parameter is present

I’m not sure it quite works like that. Try inspecting $query->public_query_vars instead and I think you’ll see it added in there. The way I usually use it is like this: add_filter( ‘query_vars’, ‘add_test_query_vars’); function add_test_query_vars($vars){ $vars[] = “test”; return $vars; } So the same as you but with a named function. Then I add a … Read more

get_query_var not working for subdirectory

You shouldn’t use get_query_var for getting the pagename (slug) – there is no guarantee that pagename will be set, depending on your permalink structure (or lack thereof). Instead, check if the request is for a page, and then get the slug directly from the queried object: if ( is_page() ) { $slug = get_queried_object()->post_name; }

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)