2 added 49 characters in body
source | link

The parse_query action gets called on every query (menu items, sidebar recent posts widgets, etc.), but get_query_var pulls from the main query, so that condition will be true for all queries despite the fact that the query var doesn't exist in those queries. You need to check the query object passed to your function hooked to parse_query:

add_action('parse_query', 'query_var'); 
function query_var( $query ) { 
  if ( isset( $query->query_vars['Q1'] ) ){    
    echo ('hello');    
  }
}

The parse_query action gets called on every query, but get_query_var pulls from the main query, so that condition will be true for all queries despite the fact that the query var doesn't exist in those queries. You need to check the query object passed to your function hooked to parse_query:

add_action('parse_query', 'query_var'); 
function query_var( $query ) { 
  if ( isset( $query->query_vars['Q1'] ) ){    
    echo ('hello');    
  }
}

The parse_query action gets called on every query (menu items, sidebar recent posts widgets, etc.), but get_query_var pulls from the main query, so that condition will be true for all queries despite the fact that the query var doesn't exist in those queries. You need to check the query object passed to your function hooked to parse_query:

add_action('parse_query', 'query_var'); 
function query_var( $query ) { 
  if ( isset( $query->query_vars['Q1'] ) ){    
    echo ('hello');    
  }
}
1
source | link

The parse_query action gets called on every query, but get_query_var pulls from the main query, so that condition will be true for all queries despite the fact that the query var doesn't exist in those queries. You need to check the query object passed to your function hooked to parse_query:

add_action('parse_query', 'query_var'); 
function query_var( $query ) { 
  if ( isset( $query->query_vars['Q1'] ) ){    
    echo ('hello');    
  }
}