Skip to main content
corrected code formatting
Source Link
s_ha_dum
  • 65.5k
  • 13
  • 84
  • 174

I wish to create a new variable as described in the codex  ,

  but on submission of the URL thethe variables are submitted twice to my function

iI have tried this within a plugin also a the functionfunction.php.php i I have also tried to use wp_reset_query()wp_reset_query()

Here is my sample code

add_filter('query_vars', 'my_function');

function my_function ($vars) {

$vars[] = 'Q1'; $vars[] = 'Q2';

return $vars;

}

add_action('parse_query', 'query_var');

function query_var () {

if (get_query_var('Q1')){

echo ('hello');:

}

add_filter('query_vars', 'my_function');
function my_function ($vars) {    
  $vars[] = 'Q1';
  $vars[] = 'Q2';    
  return $vars;    
}

add_action('parse_query', 'query_var');    
function query_var () {    
  if (get_query_var('Q1')){    
    echo ('hello');    
  }
}

I wish to create a new variable as described in the codex  ,

  but on submission of the URL the variables are submitted twice to my function

i have tried this within a plugin also a the function.php i have also tried to use wp_reset_query()

Here is my sample code

add_filter('query_vars', 'my_function');

function my_function ($vars) {

$vars[] = 'Q1'; $vars[] = 'Q2';

return $vars;

}

add_action('parse_query', 'query_var');

function query_var () {

if (get_query_var('Q1')){

echo ('hello');

}

I wish to create a new variable as described in the codex, but on submission of the URL the variables are submitted twice to my function

I have tried this within a plugin also a the function.php. I have also tried to use wp_reset_query()

Here is my sample code:

add_filter('query_vars', 'my_function');
function my_function ($vars) {    
  $vars[] = 'Q1';
  $vars[] = 'Q2';    
  return $vars;    
}

add_action('parse_query', 'query_var');    
function query_var () {    
  if (get_query_var('Q1')){    
    echo ('hello');    
  }
}
Source Link

Variables posting twice

I wish to create a new variable as described in the codex ,

but on submission of the URL the variables are submitted twice to my function

i have tried this within a plugin also a the function.php i have also tried to use wp_reset_query()

Here is my sample code

add_filter('query_vars', 'my_function');

function my_function ($vars) {

$vars[] = 'Q1'; $vars[] = 'Q2';

return $vars;

}

add_action('parse_query', 'query_var');

function query_var () {

if (get_query_var('Q1')){

echo ('hello');

}