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.

This is an odd problem that I have never run into before with WordPress.

I have a site, permalinks enabled.

The url can be http://mysite.com/page-name/?anyParamName=testing

then when I use print_r($_GET); or echo $_GET["anyParamName"] I get an empty array or nothing respectively.

A pure PHP file works fine so its not a server issue. Does WordPress do anything with rewiring the get params? Really puzzled by this.

share|improve this question
    
Where are you putting print_r( $_GET ) etc? In a theme file? –  Boone Gorges Mar 19 '12 at 19:01
    
I've tried it all over the page.php template file, even before the header. –  wesbos Mar 19 '12 at 19:03

1 Answer 1

For custom parameters you should register them with WordPress:

add_action('init','wpse46108_register_param');
function wpse46108_register_param() { 
    global $wp; 
    $wp->add_query_var('anyParamName'); 
}

Then the value of 'anyParamName' can be found with get_query_var

$anyParamNameValue = get_query_var('anyParamName').
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.