Created
May 9, 2016 12:46
-
-
Save timersys/1eaa6ed10e2dea0e9a972733acd3ded0 to your computer and use it in GitHub Desktop.
Show different WordPress menus depending on user country.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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