$_GET and WordPress $_GET and WordPress wordpress wordpress

$_GET and WordPress


See the solution :

In order to be able to add and work with your own custom query vars that you append to URLs, (eg: www.site.com/some_page/?my_var=foo - for example using add_query_arg()) you need to add them to the public query variables available to WP_Query. These are built up when WP_Query instantiates, but fortunately are passed through a filter query_vars before they are actually used to populate the $query_vars property of WP_Query.

For your case :

  function add_query_vars_filter( $vars ){       $vars[] = "size";       return $vars;  }  add_filter( 'query_vars', 'add_query_vars_filter' );

and on your template page call the get methode like that :

$size_var = (get_query_var('size')) ? get_query_var('size') : false;if($size_var){   // etc...}

More at the Codex : http://codex.wordpress.org/Function_Reference/get_query_var

I hope it helps !


Not sure if this will show anything but try turning on error reporting with:

<?php   error_reporting(E_ALL);   ini_set('display_errors', true);?>

at the top of your page before any other code.

Edit:

From the OP comments:

silly question, but are you sure youare viewing the results of your latestchanges to the file and not a cachedcopy of the page or something? Change"hello world" to something else.(Sorry grasping at straws, but thishappened to me before) – Zenshai

ahaha, the person thatwere doing the changes didn't changedthe correct file. It's working now –marcgg

peer programming fail ^^ – marcgg

That would be an "or something",can't tell you how many times i'vedone something like that. Glad youwere able to figure it out in the end.– Zenshai

I usually discover errors like these only when they begin to defy everything I know about a language or an environment.


Try this:

<?echo "hello world";?><?   if (array_key_exists('size', $_GET))    echo $_GET['size'];?><?echo "end";?>

If you see

hello worldend

... that means you're not setting the size GET parameter. What URL are you using to access said page?