Skip to content

Instantly share code, notes, and snippets.

@timersys
Created May 9, 2016
Embed
What would you like to do?
Show different WordPress menus depending on user country.
<?php
/**
* Show different WordPress menus depending on user country
* by using Geotargeting plugin API functions
* https://timersys.com/plugins/geotargeting-pro/
**/
if( function_exists( 'geot_target' ) ) {
//USA menu
if( geot_target( 'US' ) ) {
wp_nav_menu( array(
'menu' => 'USA Nav'
) );
} elseif( geot_target( 'AR' ) ) {
wp_nav_menu( array(
'menu' => 'Argentina Nav'
) );
} else {
// show default
wp_nav_menu( array(
'menu' => 'Default Nav'
) );
}
} else {
// if plugin is not active show a default menu
wp_nav_menu( array(
'menu' => 'Default Nav'
) );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment