How to set add_query_arg properly for home page?
I want to add lang
query variable to existing URL.
I have registered query variable:
add_filter('query_vars', 'custom_add_query_vars');
function custom_add_query_vars($vars){
$vars[] = lang;
return $vars;
}
The following code works good everywhere but not when I'm currently on the home page.
?php global $wp; ?
a href=?php echo add_query_arg(array('lang' = 'en'), $wp-request); ?English/a
Is there a problem with the code? On the homepage
URL becomes http://localhost/mywebsitename/?lang=en
which should be ok but supposedly it tries to load index.php
instead of page.php
, which generally wouldn't be a problem but in that case some things like is_front_page()
don't behave as it should.
Static page is set as a homepage under Settings-Reading and pretty permalinks are active (Post name option).
Topic url-rewriting permalinks Wordpress
Category Web