QueryString dropped when using Permalinks
-
I have been unable to reach the query string when I try to use the built in Day and name permalink structure. Let me explain with the following example
The following is setup in my plugin file:
function custom_rewrite_tag() { global $wp; $wp->add_query_var('code'); } add_action('init', 'custom_rewrite_tag', 10, 0); add_action( 'wp', 'test' ); function test($wp){ if( 'marketplace' == $wp->query_vars['pagename'] ){ print_r($wp); } print_r( get_query_var('code')); }If I try to go to http://localhost/marketplace/?code=123 and I look at the output I cant see the value of code as is seen below
WP Object ... [query_vars] => Array ( [pagename] => marketplace ) [query_string] => pagename=marketplace [request] => marketplace [matched_rule] => ^marketplace/? [matched_query] => pagename=marketplace [did_permalink] => 1 )while if I go to http://localhost/?code=123&pagename=marketplace and I look at the output I see the value of code as is below
WP Object ... [query_vars] => Array ( [pagename] => marketplace [code] => 123 ) [query_string] => pagename=marketplace&code=123 [request] => [matched_rule] => [matched_query] => [did_permalink] => ) 123I am not sure why this behaviour is happening, I have even tried using custom rewrite rules and still no success. Any suggestions on this is greatly appreciated.
The topic ‘QueryString dropped when using Permalinks’ is closed to new replies.