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 add pamarameters to URLs that are read by javascript widgest/gadgets run on the site.

Whenever I just add them e.g. the original URL is http://example.com/blog/page/ and the parameter is called foo with a value called bar.

The new URL becomes: http://example.com/blog/page/?foo=bar

The original URL is working fine, but the new URL is giving a 404. I assume that I need to register any additional parameter so that this works first. Is this true? How can I make new URL parameters not triggering 404s?

share|improve this question
I can't follow your question(sorry), widgets don't have their own URLs. I don't see the connection between widgets and URLs, would you mind going into a bit more detail. – t31os Mar 4 '11 at 11:32
t31os - I'm talking about some html/javascript widgets here, not Wordpress PHP widgets. So this might be the missing link. It's a pretty general question. A more correct alternative question might be: Why does adding stuff to the query-info part of an URL causes 404 responses by wordpress? – hakre Mar 4 '11 at 13:01
Oddly pages with query vars seem to only work when the first uses var uses a ? and not an &, which is odd considering the page name is technically the first query var(must have changed in 3.1, i don't remember this occuring in 2.9-3.0). – t31os Mar 4 '11 at 17:17
@t31os - the site in question is running WP 3.0.3, I'll suggest the owner to upgrade it to 3.0.5 at least. – hakre Mar 7 '11 at 13:31

I think you just need to add it to the query vars

add_filter( 'query_vars', 'my_query_vars' ); 
function my_query_vars( $query_vars ) {     
    $query_vars[] = 'foo';
    return $query_vars;
share|improve this answer
Just would like to know if this is "think" is a "guess" or a "know". Thanks. – hakre Mar 4 '11 at 11:24
In this case "Think" = if i remember correctly – Bainternet Mar 4 '11 at 11:31
Thanks for clarifying. It's something I assumed as well but I just wonder why this is actually triggering a 404. As the vars are not registered, WP shouldn't care at all. I think I need to review that, will report back. – hakre Mar 4 '11 at 12:56
I did now test your suggestion but adding the query variables did not work. The 404 error still occurs. – hakre Mar 7 '11 at 13:29
@baked i have done some deeper digging and need some feedback from you, does the 404 happen when using the default permalink structure? If not then you would need to create a rewrite rule to fix it. – Bainternet Mar 7 '11 at 16:33
up vote 0 down vote accepted

I found the answer to my question.

There is no need register query vars for this but instead to take care to not use some of the core query vars as this will break things.

In my case it was the year query variable which caused the 404.

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.