Different Menus for Different Countries
-
I want to assign different menus based on a user’s location. I’ve installed the GeoIP Detection plugin and assigned the variable $userInfo = geoip_detect2_get_info_from_current_ip() in functions.php and verified it works. I also created two different menus called ‘Main Menu’ and ‘Main Menu International’.
By default, the menu “Main Menu International” (ID 303) is assigned to theme locations “Main Menu” and “Main Menu – Mobile”.
But how do I assign the menu “Main Menu” (ID 51) to both main and mobile theme locations when isoCode = “TH”?
Here’s what I have so far. I need help with figuring out where to put this code, and how edit it to make it assign the menu to both “main” and “mobile” locations.
<?php
if ( $userInfo->country->isoCode == ‘TH’ ){
wp_nav_menu(array(‘menu_id’ => 51)); //Main Menu ID
} else {
wp_nav_menu(array(‘menu_id’ => 303)); //Main Menu International ID
}
?>
- The topic ‘Different Menus for Different Countries’ is closed to new replies.