php - Setting Wordpress Primary Menu Programatically -


i have 2 menus created via end. need activate menu based on geo location, have aleady setup set default currency. menu names in backend main , main international. below code:

function geo_client_currency($client_currency){ $userinfo = geoip_detect2_get_info_from_current_ip();  if ($userinfo->country->isocode == 'us'){     $client_currency = 'usd'; //currency code     } else {     $client_currency = 'inr'; }  return $client_currency; } 

so need set main menu , main international anywhere outside us. have reviewed codex not quite sure how implement easiest way possible

could easy in template file (like header.php)?

<?php     $userinfo = geoip_detect2_get_info_from_current_ip();     if ( $userinfo->country->isocode == 'us' ){         wp_nav_menu(array('menu_id' => 1)); //change 1 main id     } else {         wp_nav_menu(array('menu_id' => 2)); //change 2 main international id     } ?> 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -