WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to generate a simple error message on a page by passing a variable through the URL.

The URL is structured as follows:


I'm sure it's the permalinks rewrite interfering, but I'm not sure how to resolve it.

share|improve this question
You need to know you to generate using $_GET variable, or how to add query args in url? – Mamaduka Feb 6 '12 at 17:18
up vote 8 down vote accepted

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)


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

function add_my_error() { 
    global $wp; 
share|improve this answer
Exactly what I needed, thanks! – Kyle Feb 6 '12 at 17:24
I wouldn't use that filter in particular. We have functions that you should use for that instead. add_action('init','add_my_error'); function add_my_error() { global $wp; $wp->add_query_var('my_error'); } – Otto Feb 6 '12 at 20:49
Thanks @Otto - I've added your comment to the answer. – Stephen Harris Feb 6 '12 at 20:58
Cool. It doesn't really matter, actually, I just prefer to not use deep hooks when shallow ones will do the job. :) – Otto Feb 6 '12 at 21:01
I always use add_rewrite_tag($tagname,$regex). Any difference? – Rob Vermeer Feb 6 '12 at 21:10

This was the only way I could get this to work

function add_query_args()
    add_query_arg( 'error', 'pause' );


share|improve this answer

Your Answer


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.