How to add URL-Parameter for Javascript Widgets?

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.

Read More

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?

Related posts

Leave a Reply

2 comments

  1. 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;
    }
    
  2. 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.