-
-
Save rodelrod/ed1cd3d2edf5c2f0ee7b04c87b2b795c to your computer and use it in GitHub Desktop.
Geotargeting redirects
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 | |
/** | |
* Create Custom Redirects from home page only | |
* @link http://wp.timersys.com/geotargeting/ | |
* | |
* @wordpress-plugin | |
* Plugin Name: GeoTargeting Pro Custom Redirects | |
* Plugin URI: http://wp.timersys.com/geotargeting/ | |
* Description: Geo Targeting custom redirects | |
* Version: 1.0.0 | |
* Author: Timersys | |
* Author URI: http://wp.timersys.com/geotargeting/ | |
*/ | |
add_action( 'init', 'geot_custom_redirects'); | |
function geot_custom_redirects() { | |
global $geot; | |
// if main plugin is not enabled return | |
if( ! function_exists( 'geot_target' ) ) | |
return; | |
// if search engine exit | |
if( $geot->functions->isSearchEngine() ) | |
return; | |
// if is admin user or backend return | |
//if( is_admin() ) | |
// return; | |
// if not in home page return | |
if( ! is_front_page() ) | |
return; | |
if( geot_target( 'US' ) ) { | |
wp_redirect( 'http://domain.com/us-home-page' ); | |
die(); | |
} | |
if( geot_target('', 'Other Region name you created' ) ) { | |
wp_redirect( 'http://domain.com/ca-home-page' ); | |
die(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment