Using $_GET variables in the URL?

Try adding the variable to the WordPress’ array of ‘recognised query variables’…

add_filter('query_vars', 'my_register_query_vars' );
function my_register_query_vars( $qvars ){
    //Add query variable to $qvars array
    $qvars[] = 'my_error';
    return $qvars;
}

Then the value of ‘my_error’ can be found via get_query_var('my_error'). (See Codex)

EDIT

From Otto’s comment, it’s better to do:

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

Leave a Comment