Skip to content

Instantly share code, notes, and snippets.

@timersys
Created May 9, 2016 12:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timersys/1eaa6ed10e2dea0e9a972733acd3ded0 to your computer and use it in GitHub Desktop.
Save timersys/1eaa6ed10e2dea0e9a972733acd3ded0 to your computer and use it in GitHub Desktop.
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